home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0050 / cb_sourc.e / cb.c next >
C/C++ Source or Header  |  1997-04-16  |  80KB  |  3,105 lines

  1. /*************************************************************/
  2. /*        Color Burst II ST/STe version 1.3                  */
  3. /*             September 25th 1990                           */
  4. /*************************************************************/
  5. #include "cbnew.h"
  6. #include <linea.h>
  7. #include <fcntl.h>
  8. #include <gemdefs.h> 
  9. #include <obdefs.h>
  10. #include <osbind.h>
  11. #include <stdio.h>
  12. #define PAUSE(a) pause_flag=1;while(vcount<a);pause_flag=0
  13. #define RING_BELL() Bconout(2,7) 
  14. #define HELP 0x6200
  15. #define UNDO 0x6100
  16. #define BACKSPACE 0x0E08
  17. #define DELETE 0x537F
  18. #define SPACE 0x3920
  19. #define CNTL_C 0x2e03
  20. #define CNTL_Z 0x2c1a
  21. #define CNTL_Y 0x1519
  22. #define CNTL_X 0x2D18
  23. #define CNTL_T 0x1414
  24. #define C      0x2E43
  25. #define sC     0x2E63
  26. #define T      0x1474
  27. #define sT     0x1454
  28. #define S      0x1F53
  29. #define sS     0x1F73
  30. #define M      0x324D
  31. #define sM     0x326D
  32. #define E      0x1245
  33. #define sE     0x1265
  34. #define CLEAR  0x4700
  35. #define ESC 0x011B
  36. #define F1  0x3B00
  37. #define F2  0x3C00
  38. #define F3  0x3D00
  39. #define F4  0x3E00
  40. #define F5  0x3F00
  41. #define F6  0x4000
  42. #define F7  0x4100
  43. #define F8  0x4200
  44. #define F9  0x4300 
  45. #define F10 0x4400
  46.  
  47. #define TRUE   1
  48. #define SAVE_S 1
  49. #define SAVE_Z 2
  50. #define FALSE  0
  51. #define NEW    2
  52. #define OLD    1
  53. #define NEITHER  0
  54. #define LEFT     1
  55. #define RIGHT    2
  56. #define BOTH     3
  57. #define NO_REDRAW  2
  58. #define TRANSPARENT 2
  59. #define OVERWRITE   1
  60. #define LOW     0
  61. #define MEDIUM  1
  62. #define TEN     10  /* Max number of screens */
  63.  
  64.     extern long save_A4();
  65.     extern int  global[];
  66.  
  67.     lineaport *myport;
  68.  
  69.     OBJECT *dialog,*help_1,*help_2,*help_3,*help_4,*credits,
  70.            *colorbox,*colorset,*drawmode,*rom_vers;
  71.  
  72.     int    my_control[8000];
  73.     long   test,my_buffer[8000];
  74.     
  75.     char   default_drive,filename[81],s[81];
  76.  
  77.     int    gl_hchar,gl_wchar,gl_wbox,gl_hbox,ap_id,message[8],handle,
  78.            contrl[12],intin[128],ptsin[128],intout[128],spray_xr=16,width,
  79.            spray_yr=8,ptsout[128],work_in[11],work_out[57],KEY,old_pen=3,
  80.            height=0,vcount=0,pause_flag,ptoggle=1,copy_mode=3,lwidth=1,
  81.            desk_palette[16],pic_palette[10][16],palette[16],max_num_screens,
  82.            my_palette[16]={ 0x000,0x700,0x007,0x777,0x500,0x252,0x333,
  83.            0x224,0x727,0x266,0x047,0x470,0x407,0x740,0x074,0x704 },
  84.            map[16]={0,2,3,6,4,7,5,8,9,10,11,14,12,15,13,1},text_h,
  85.            medmap[4]={0,2,3,1},cb1_palette[3200],cb2_palette[3200],
  86.            cb_pal[10][3200],set_flag=LINE_S,active_pen,old_shade[16],
  87.            linewmode=1,textwmode=2,textstyle=0,demo_count=0,max_shade,
  88.            STe_rgb[16]={0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15},
  89.            STe_exists,locked=TRUE,d1,d2,d3,d4,list[200];
  90.  
  91.     long   menu_address,MASK,SPRITE,SHOWN,HIDDEN,SCREEN[10],temp_line,
  92.            RAW_HIDDEN;
  93.  
  94.     int    _1st_enable_register,_2nd_enable_register,hblank(),vblank(),
  95.            _1st_mask_register,timer_setup(),clean_up(),pseudo_burst(),
  96.            clear_vblank(),exit_to_desktop();
  97.     unsigned myseed;
  98.     
  99.     char   Linked[] = " Linked ", 
  100.            Unlinked[] = "Unlinked",
  101.            Pal_linked[] = " Palettes Linked ",
  102.            Pal_unlinked[] = "Palettes Unlinked";
  103.  
  104.     static char exit_text[] =
  105.       "[1][ | EXIT PROGRAM | Have you saved | your work? ][ EXIT | Cancel ]",
  106.        clear_text[] = "[0][ | Clear Current Screen ?   | ][ Yes | No ]";
  107.  
  108.     union {int tos_version; char part[2];}rom_version;
  109.     
  110. main()
  111.     {
  112.     int back=TRUE,last=TRUE;
  113.     setup();
  114.     do_introduction();
  115.     while( back != FALSE) 
  116.        {
  117.        back = get_event(last);
  118.        last = back;
  119.        }
  120.     exit_to_desktop();
  121.     }
  122.  
  123.  
  124.  
  125. setup()
  126.     {
  127.     int I,J,K,N,r,g,b,clip[4];
  128.         /***** Basic ST Gem Set up *****/
  129.     ap_id = appl_init();
  130.     handle = graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox);
  131.     for(I=0;I<10;work_in[I++]=1);
  132.     work_in[10]=2;
  133.     v_opnvwk(work_in,&handle,work_out);
  134.     clip[0] = clip[1] =0;
  135.     clip[2] = work_out[0];
  136.     clip[3] = work_out[1];
  137.     vs_clip(handle,TRUE,clip);
  138.     myseed=1;
  139.         /***** Load & Set Resource File *****/    
  140.     rsrc_load("cbnew.rsc");
  141.     rsrc_gaddr(R_TREE,TOP_MENU,&menu_address);
  142.     rsrc_gaddr(R_TREE,TOOL_BOX,&dialog);
  143.     rsrc_gaddr(R_TREE,HELP_1,&help_1);
  144.     rsrc_gaddr(R_TREE,HELP_2,&help_2);
  145.     rsrc_gaddr(R_TREE,HELP_3,&help_3);
  146.     rsrc_gaddr(R_TREE,HELP_4,&help_4);
  147.     rsrc_gaddr(R_TREE,CREDITS,&credits);
  148.     rsrc_gaddr(R_TREE,COLORBOX,&colorbox);
  149.     rsrc_gaddr(R_TREE,DRAWMODE,&drawmode);
  150.     rsrc_gaddr(R_TREE,ROM_VERS,&rom_vers);
  151.         /***** Program Set up *****/
  152.     myport = a_init();
  153.     default_drive = Dgetdrv() + 'A' ;
  154.     graf_mouse(ARROW,0);
  155.     v_hide_c(handle);
  156.     for(I=0;I<16;desk_palette[I++]=Setcolor(I,-1));
  157.     if(Getrez()==0)
  158.       {
  159.       I = my_palette[3];
  160.       my_palette[3] = my_palette[15];
  161.       my_palette[15] = I;
  162.       }
  163.     STe_exists = show_tos_version();            /* Does an STe exist? */
  164.     vsf_color(handle,3);
  165.     vsf_interior(handle,1);
  166.     vsf_style(handle,16);
  167.     vsl_width(handle,1);
  168.     vr_recfl(handle,clip);
  169.     vsf_color(handle,2);
  170.     vst_color(handle,2);
  171.     vsm_color(handle,2);
  172.     vsl_color(handle,2);
  173.     vsf_color(handle,2);
  174.     active_pen = 2;
  175.     text_h=6;
  176.     shadow_text(30,70,"Color Burst II ST/STe",2,TRANSPARENT);
  177.     shadow_text(30,85,"Version 1.3 ",2,TRANSPARENT);
  178.          /***** Allocate Screen Memory Buffers *****/
  179.     max_num_screens=0;
  180.     SPRITE  = ((Malloc(32768L) & 0xffff00 ) + 0x0100);
  181.     MASK    = ((Malloc(32768L) & 0xffff00 ) + 0x0100);
  182.     clear_screen(SPRITE);
  183.     clear_screen(MASK);
  184.     SHOWN = Physbase();
  185.     HIDDEN = SCREEN[0] = (((RAW_HIDDEN=Malloc(32768L)) & 0xffff00 ) 
  186.     + 0x0100);
  187.     KEY = 0;
  188.     for(I=1;(I<TEN && SCREEN[I-1]>0x0200);I++) 
  189.        {
  190.        SCREEN[I] = ((Malloc(32768L) & 0xffff00 ) + 0x0100);
  191.        max_num_screens = I;
  192.        }
  193.     if(SCREEN[I]<0x0200)max_num_screens--;
  194.     copy_picture(SHOWN,SCREEN[0]);
  195.     for(J=0;J<3200;J++)
  196.       {
  197.       r=my_palette[J%16]&0x0f00;
  198.       g=my_palette[J%16]&0x00f0;
  199.       b=my_palette[J%16]&0x000f;
  200.       if(STe_exists == TRUE)
  201.         { 
  202.         r=(r>0x0700) ? 0x4000 + (r-0x800)*2 : r*2;
  203.         g=(g>0x0070) ? 0x2000 + (g-0x080)*2 : g*2;   /* STe mode        */
  204.         b=(b>0x0007) ? 0x1000 + (b-0x008)*2 : b*2;
  205.         }
  206.       else
  207.         {
  208.         r *=2;
  209.         g *=2;                                       /* normal ST mode */
  210.         b *=2;
  211.         }
  212.       cb_pal[0][J]=r+g+b;
  213.       }
  214.     for ( I = 1; I <= max_num_screens; I++) 
  215.       {
  216.       copy_picture(SHOWN,SCREEN[I]);
  217.       for(J=0;J<3200;J++)cb_pal[I][J]=cb_pal[0][J];
  218.       }
  219.     N = 30;
  220.     for ( J=2; J < 3200; J += 16 )
  221.       {
  222.       b = N;
  223.       if ( N >30 ) b = 60-N;
  224.       if ( N >60 ) b = N-60;
  225.       if ( N >90 ) b = 120-N;
  226.       if ( N >120) b = N-120;
  227.       if ( N >150) b = 180-N;
  228.       if ( N >180) b = N-180;
  229.       if ( N >210) b = 240-N;
  230.       N += 1;
  231.       if(STe_exists == TRUE)
  232.         { 
  233.         b=(b>0x000f) ? 0x1000 + (b-0x010) : b;
  234.         }
  235.       else
  236.         {
  237.         b = (b-1)/2;
  238.         }
  239.       cb_pal[0][J] = b;
  240.       }
  241.     stuff_current_cbpal(NEW);
  242.     for(I=0;I<200;I++)list[I]=0;
  243.     reset_color(NEW);
  244.     v_show_c(handle,0);
  245.     }
  246.  
  247.  
  248.  
  249. exit_to_desktop()
  250.     {
  251.     RING_BELL();
  252.     Setpalette(desk_palette);
  253.     v_show_c(handle,0);
  254.     Supexec(clear_vblank);
  255.     v_clsvwk(handle);
  256.     v_clrwk(handle);
  257.     appl_exit();
  258.     }
  259.  
  260.  
  261.  
  262. do_introduction()
  263.     {
  264.     int bx,by,bw,bh,I;
  265.     form_center(credits,&bx,&by,&bw,&bh);
  266.     v_hide_c(handle);
  267.     form_dial(FMD_GROW,0,0,10,10,10,10,30,169);
  268.     form_dial(FMD_GROW,10,169,30,30,work_out[0]-bw,166,bw,32);
  269.     form_dial(FMD_GROW,work_out[0]-bw,166,bw,32,bx,by,bw,bh);
  270.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  271.     RING_BELL();
  272.     objc_draw(credits,0,10,bx,by,bw,bh);
  273.     goto_colorburst_mode(800);
  274.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  275.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  276.     copy_picture(HIDDEN,SHOWN);
  277.     v_show_c(handle,0);
  278.     }
  279.  
  280.  
  281.  
  282. check_tool_box(x,y,bx,by,bw,bh)
  283.     int x,y,bx,by,bw,bh;
  284.     {
  285.     int selection,button,d;
  286.     selection=objc_find(dialog,0,1,x,y);
  287.     switch(selection)
  288.       {
  289.       case CIRCLE:
  290.       case BOX:
  291.       case FREEHAND:
  292.       case SPRAY:
  293.       case STIPPLE:
  294.       case LINEFAN:
  295.       case ZOOM:
  296.       case FILL:
  297.       case TEXT:
  298.       case COLORS:
  299.        case CUT_SPR:
  300.       case PASTE:
  301.       case VERTICAL:
  302.       case HORIZON:
  303.       case MENU:
  304.       case QUARTER:
  305.       case HIDETOOL:
  306.          v_hide_c(handle);
  307.          form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  308.          form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  309.          copy_picture(HIDDEN,SHOWN);
  310.          v_show_c(handle,0);
  311.          break;
  312.       case LOCK_INF:
  313.          if (locked==TRUE)
  314.            {
  315.            ((TEDINFO *) dialog[LOCK_INF].ob_spec)->te_ptext = Unlinked;
  316.            locked = FALSE;
  317.            }
  318.          else
  319.            {
  320.            ((TEDINFO *) dialog[LOCK_INF].ob_spec)->te_ptext = Linked;
  321.            locked = TRUE;
  322.            }
  323.          ((TEDINFO *) dialog[LOCK_INF].ob_spec)->te_txtlen = 8;
  324.          objc_offset(dialog,LOCK_INF,&d1,&d2);
  325.          d3 = dialog[LOCK_INF].ob_width;
  326.          d4 = dialog[LOCK_INF].ob_height;
  327.          objc_draw(dialog,LOCK_INF,1,d1,d2,d3,d4);
  328.          while (button != NONE)vq_mouse(handle,&button,&x,&y);
  329.       default:
  330.          return(NO_REDRAW);
  331.          break;
  332.       }
  333.     switch(selection)
  334.       {
  335.       case CIRCLE:
  336.          make_ellipse();
  337.          break;
  338.       case BOX:
  339.          make_box();
  340.          break;
  341.       case FREEHAND:
  342.          free_hand();
  343.          break;
  344.       case SPRAY:
  345.          spray_can();
  346.          break;
  347.       case STIPPLE:
  348.          stippler();
  349.          break;
  350.       case LINEFAN:
  351.          linefan();
  352.          break;
  353.       case TEXT:
  354.          edit_text();
  355.          break;
  356.       case FILL:
  357.          fill_it();
  358.          break;
  359.        case CUT_SPR:
  360.          edit();
  361.          break;
  362.       case PASTE:
  363.          paste_sprite();
  364.          break;
  365.       case VERTICAL:
  366.          flip_vertical();
  367.          break;
  368.       case HORIZON:
  369.          flip_horizontal();
  370.          break;
  371.       case QUARTER:
  372.          quarter_screen();
  373.          break;
  374.       case MENU:
  375.          if( get_menu() == FALSE) return(FALSE);
  376.          break;
  377.       case HIDETOOL: 
  378.          button = NONE;
  379.          goto_colorburst_mode(1000);
  380.          break;
  381.       case ZOOM:
  382.          zoom_edit();
  383.          break;
  384.       case COLORS:
  385.          set_pen();
  386.          break;
  387.       }
  388.     graf_mouse(ARROW,0);
  389.     copy_picture(SHOWN,HIDDEN);
  390.     return(TRUE);
  391.     }
  392.  
  393.  
  394.  
  395. get_menu()
  396.     {
  397.     int event,message[8],x,y,button,state,key,n,I;
  398.     unsigned size;
  399.     long off[2];
  400.     v_hide_c(handle);
  401.     copy_picture(HIDDEN,SHOWN);
  402.     menu_bar(menu_address,TRUE);
  403.     v_show_c(handle,0);
  404.     clear_keyboard();
  405.     for(;;)
  406.       {
  407.       event = evnt_multi(MU_MESAG|MU_BUTTON|MU_KEYBD,1,3,1,0,0,0,0,
  408.               0,0,0,0,0,0,message,0,0,&x,&y,&button,&state,&key,&n);
  409.       if(event==MU_MESAG && message[0]==10)
  410.         {
  411.         v_hide_c(handle);
  412.         menu_tnormal(menu_address,message[3],1);
  413.         menu_bar(menu_address,FALSE);
  414.         copy_picture(HIDDEN,SHOWN);
  415.         v_show_c(handle,0);
  416.         switch(message[4])
  417.            {
  418.            case TITLE:
  419.               show_credits();
  420.               break;
  421.            case PICTUREL:
  422.            case NEO:
  423.            case DEGAS:
  424.               if(select_picture(message[4],&size,off)!=FALSE) 
  425.                 load_picture(size,off);
  426.               copy_picture(HIDDEN,SHOWN);
  427.               break;
  428.            case QUIT:
  429.               return(FALSE);
  430.               break;
  431.            case S_NEO:
  432.            case S_DEGAS:
  433.            case PICTURES:
  434.               if(select_picture(message[4],&size,off)!=FALSE) 
  435.                 save_picture(size,off);
  436.               copy_picture(HIDDEN,SHOWN);
  437.               break;
  438.            case PROGRAM:
  439.               call_other_program();
  440.               break;
  441.            case HIDE:
  442.               return(TRUE);
  443.               break;
  444.            }
  445.         v_hide_c(handle);
  446.         menu_bar(menu_address,TRUE);
  447.         v_show_c(handle,0);
  448.         }
  449.       if (event == MU_BUTTON)
  450.         {
  451.         v_hide_c(handle);
  452.         menu_bar(menu_address,FALSE);
  453.         copy_picture(HIDDEN,SHOWN);
  454.         menu_bar(menu_address,TRUE);
  455.         v_show_c(handle,0);
  456.         }
  457.       if (event == MU_KEYBD)
  458.         {
  459.         v_hide_c(handle);
  460.         menu_bar(menu_address,FALSE);
  461.         copy_picture(HIDDEN,SHOWN);
  462.         v_show_c(handle,0);
  463.         switch(key)
  464.           {
  465.           case CNTL_C:
  466.           case CNTL_Z:
  467.           case CNTL_Y:
  468.           case ESC:
  469.               return(FALSE);
  470.               break;
  471.           case T:
  472.           case sT:
  473.               return(TRUE);
  474.               break;              
  475.           case S:
  476.           case sS:
  477.           case C:
  478.           case sC:
  479.           case E:
  480.           case sE:
  481.               set_pen();
  482.               break;
  483.           case CLEAR:
  484.               if(form_alert(1,clear_text)==1)
  485.                  {
  486.                  clear_screen(HIDDEN);
  487.                  copy_picture(HIDDEN,SHOWN);
  488.                  }
  489.               break;
  490.           case SPACE:
  491.               copy_picture(HIDDEN,SHOWN);
  492.               goto_colorburst_mode(400);
  493.               break;
  494.           case BACKSPACE:
  495.               for(I=0;I<16;I++)palette[I]=my_palette[I];
  496.               Setpal(palette);
  497.               break;
  498.           case HELP:
  499.               display_help();
  500.               break;
  501.           case F1:                      /* Change Active Buffer */
  502.           case F2:
  503.           case F3:
  504.           case F4:
  505.           case F5:
  506.           case F6:                      /* 'key' becomes active */
  507.           case F7:                      /* buffer.              */
  508.           case F8:
  509.           case F9:
  510.           case F10:
  511.               trade_buffers(key,x,y,40,40,2,2); 
  512.               break;
  513.          }
  514.         v_hide_c(handle);
  515.         menu_bar(menu_address,TRUE);
  516.         v_show_c(handle,0);
  517.         }
  518.       }
  519.     }
  520.  
  521.  
  522.  
  523. get_event(last)
  524.     int last;
  525.     {
  526.     int event,message[8],x,y,button,state,key,n,I,
  527.         bx,by,bw,bh,sx,sy,sw,sh;
  528.     if(last==TRUE)
  529.       {
  530.       form_center(dialog,&bx,&by,&bw,&bh);
  531.       sx=work_out[0]-31;
  532.       sy=160;
  533.       v_hide_c(handle);
  534.       form_dial(FMD_GROW,0,0,10,10,sx,sy,30,30);
  535.       form_dial(FMD_GROW,sx,sy,30,30,sx-20,90,50,50);
  536.       form_dial(FMD_GROW,sx-20,90,50,50,bx,by,bw,bh);
  537.       form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  538.       if (locked==TRUE)
  539.         {
  540.         ((TEDINFO *) dialog[LOCK_INF].ob_spec)->te_ptext = Linked;
  541.         }
  542.       else
  543.         {
  544.         ((TEDINFO *) dialog[LOCK_INF].ob_spec)->te_ptext = Unlinked;
  545.         }
  546.       ((TEDINFO *) dialog[LOCK_INF].ob_spec)->te_txtlen = 8;
  547.       objc_draw(dialog,0,10,bx,by,bw,bh);
  548.       vq_mouse(handle,&button,&x,&y);
  549.       v_show_c(handle,0);
  550.       }
  551.     clear_keyboard();
  552.     event = evnt_multi( MU_BUTTON | MU_KEYBD ,1,3,1,0,0,0,0,0,0,0,0,
  553.       0,0,message,0,0,&x,&y,&button,&state,&key,&n );
  554.     if (event == MU_BUTTON ) 
  555.        {
  556.        switch(check_tool_box(x,y,bx,by,bw,bh) )
  557.          {
  558.          case FALSE:
  559.             if(form_alert(1,exit_text)==1) return(FALSE);
  560.             return(TRUE);
  561.             break;
  562.          case TRUE:
  563.             return(TRUE);
  564.             break;
  565.          }
  566.        }
  567.     if (event == MU_KEYBD )
  568.        {
  569.        switch ( key)
  570.          {
  571.          case CNTL_C:
  572.          case CNTL_Z:
  573.          case CNTL_Y:
  574.          case ESC:
  575.               if(form_alert(1,exit_text)==1) return(FALSE);
  576.               break;              
  577.          case SPACE:
  578.               copy_picture(HIDDEN,SHOWN);
  579.               return( goto_colorburst_mode(400) );
  580.               break;
  581.          case C:
  582.          case sC:
  583.          case E:
  584.          case sE:
  585.          case S:
  586.          case sS:
  587.               form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  588.               form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  589.               copy_picture(HIDDEN,SHOWN);
  590.               set_pen();
  591.               return(TRUE);
  592.               break;
  593.          case M:
  594.          case sM:
  595.               form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  596.               form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  597.               copy_picture(HIDDEN,SHOWN);
  598.               return(get_menu());
  599.               break;
  600.          case CLEAR:
  601.               if(form_alert(1,clear_text)==1)
  602.                  {
  603.                  form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  604.                  form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  605.                  clear_screen(HIDDEN);
  606.                  copy_picture(HIDDEN,SHOWN);
  607.                  return(TRUE);
  608.                  }
  609.               break;
  610.          case BACKSPACE:
  611.               for(I=0;I<16;I++)palette[I]=my_palette[I];
  612.               Setpal(palette);
  613.               break;
  614.           case HELP:
  615.               display_help();
  616.               return(TRUE);
  617.               break;
  618.          case F1:                      /* Change Active Buffer */
  619.          case F2:
  620.          case F3:
  621.          case F4:
  622.          case F5:
  623.          case F6:                      /* 'key' becomes active */
  624.          case F7:                      /* buffer.              */
  625.          case F8:
  626.          case F9:
  627.          case F10:
  628.               return(trade_buffers(key,x,y,bx,by,bw,bh)); 
  629.               break;
  630.          }
  631.        }
  632.     return(NO_REDRAW);
  633.     }
  634.  
  635.  
  636.  
  637. clear_keyboard()
  638.     {
  639.     int event,message[8],x,y,button,state,key,n;
  640.     while(event != MU_TIMER) 
  641.       event=evnt_multi(MU_BUTTON|MU_KEYBD|MU_TIMER,1,3,1,0,0,0,0,0,
  642.       0,0,0,0,0,message,300,0,&x,&y,&button,&state,&key,&n );
  643.     }
  644.  
  645.  
  646.  
  647.  
  648. set_drawing_mode()
  649.     {
  650.     int bx,by,bw,bh,cw,ch,button,x,y,selection;
  651.     v_hide_c(handle);
  652.     form_center(drawmode,&bx,&by,&bw,&bh);
  653.     form_dial(FMD_GROW,0,work_out[1],10,10,bx,by,bw,bh);
  654.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  655.     objc_draw(drawmode,0,10,bx,by,bw,bh);
  656.     v_show_c(handle,0);
  657.     vq_mouse(handle,&button,&x,&y);
  658.     while (button != BOTH)
  659.       {
  660.       vq_mouse(handle,&button,&x,&y);
  661.       if(button == LEFT)
  662.         {
  663.         selection=objc_find(drawmode,0,1,x,y);
  664.         switch(selection)
  665.           {
  666.           case DM_DRAWO:
  667.              set_object(drawmode,selection,CHECKED);
  668.              set_object(drawmode,DM_DRAWT,NORMAL);
  669.              linewmode=1;
  670.              vswr_mode(handle,linewmode);
  671.              break;
  672.           case DM_DRAWT:
  673.              set_object(drawmode,selection,CHECKED);
  674.              set_object(drawmode,DM_DRAWO,NORMAL);
  675.              linewmode=2;
  676.              vswr_mode(handle,linewmode);
  677.              break;
  678.           case DM_TEXTO:
  679.              set_object(drawmode,selection,CHECKED);
  680.              set_object(drawmode,DM_TEXTT,NORMAL);
  681.              textwmode=1;
  682.              break;
  683.           case DM_TEXTT:
  684.              set_object(drawmode,selection,CHECKED);
  685.              set_object(drawmode,DM_TEXTO,NORMAL);
  686.              textwmode=2;
  687.              break;
  688.           case DM_TEXTN:
  689.              set_object(drawmode,selection,CHECKED);
  690.              set_object(drawmode,DM_TEXTI,NORMAL);
  691.              set_object(drawmode,DM_TEXTL,NORMAL);
  692.              textstyle=0;
  693.              vst_effects(handle,0);
  694.              break;
  695.           case DM_TEXTI:
  696.              set_object(drawmode,selection,CHECKED);
  697.              set_object(drawmode,DM_TEXTN,NORMAL);
  698.              textstyle = textstyle | 0x004;
  699.              vst_effects(handle,textstyle);
  700.              break;
  701.           case DM_TEXTL:
  702.              set_object(drawmode,selection,CHECKED);
  703.              set_object(drawmode,DM_TEXTN,NORMAL);
  704.              textstyle = textstyle | 0x010;
  705.              vst_effects(handle,textstyle);
  706.              break;
  707.           case DM_DONE:
  708.              button = BOTH;
  709.              break;
  710.           }
  711.         }
  712.        }
  713.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  714.     v_hide_c(handle);
  715.     form_center(colorbox,&bx,&by,&bw,&bh);
  716.     form_dial(FMD_GROW,0,work_out[1],10,10,bx,by,bw,bh);
  717.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  718.     objc_draw(colorbox,0,10,bx,by,bw,bh);
  719.     v_show_c(handle,0);
  720.     return;
  721.     }
  722.  
  723.  
  724. set_pen()
  725.     {
  726.     int bx,by,bw,bh,cw,ch,button,x,y,w,h,r[4],
  727.         selection,c,I,attrib[6],temp,changed=FALSE;
  728.     v_hide_c(handle);
  729.     form_center(colorbox,&bx,&by,&bw,&bh);
  730.     form_dial(FMD_GROW,0,work_out[1],10,10,bx,by,bw,bh);
  731.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  732.     if (locked==TRUE)
  733.       {
  734.       ((TEDINFO *) colorbox[PAL_LOCK].ob_spec)->te_ptext = Pal_linked;
  735.       }
  736.     else
  737.       {
  738.       ((TEDINFO *) colorbox[PAL_LOCK].ob_spec)->te_ptext = Pal_unlinked;
  739.       }
  740.     ((TEDINFO *) colorbox[PAL_LOCK].ob_spec)->te_txtlen = 17;
  741.     objc_draw(colorbox,0,10,bx,by,bw,bh);
  742.     cw = colorbox[COLOR_1].ob_width;   /* Get size of color blocks */
  743.     ch = colorbox[COLOR_1].ob_height;
  744.     c = ((int)colorbox[old_pen].ob_spec) & 0x000f;
  745.     set_rgb(colorbox,old_pen,set_flag);
  746.     set_object(colorbox,old_pen,CHECKED);
  747.       if(c==1)
  748.         {
  749.         set_object(colorbox,old_pen,NORMAL);
  750.         set_object(colorbox,old_pen,DISABLED);
  751.         }
  752.     set_object(colorbox,set_flag,SELECTED);
  753.     switch(set_flag)
  754.       {
  755.       case SELECT_F:
  756.          set_fill();
  757.          break;
  758.       case SELECT_T:
  759.          set_text();
  760.          break;
  761.       case SELECT_S:
  762.          break;
  763.       case LINE_W:
  764.       case LINE_S:
  765.          set_line();
  766.          break;
  767.       }
  768.     v_show_c(handle,0);
  769.     vq_mouse(handle,&button,&x,&y);
  770.     while (button != BOTH)
  771.       {
  772.       if( Bconstat(2)) Bconin(2);
  773.       vq_mouse(handle,&button,&x,&y);
  774.       if(button == LEFT)
  775.         {
  776.         if(objc_find(colorbox,0,1,x,y)==MORE)
  777.           {
  778.           form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  779.           set_drawing_mode();
  780.           form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  781.           set_rgb(colorbox,old_pen,set_flag);
  782.           switch(set_flag)
  783.             {
  784.             case SELECT_F:
  785.                set_fill();
  786.                break;
  787.             case SELECT_T:
  788.                set_text();
  789.                break;
  790.             case SELECT_S:
  791.                break;
  792.             case LINE_W:
  793.             case LINE_S:
  794.                set_line();
  795.                 break;
  796.             }
  797.           }
  798.         selection=objc_find(colorbox,0,1,x,y);
  799.         switch(selection)
  800.           {
  801.           case SELECT_F:
  802.           case SELECT_S:
  803.           case SELECT_T:
  804.           case LINE_W:
  805.           case LINE_S:
  806.             set_object(colorbox,set_flag,NORMAL);
  807.             set_object(colorbox,LINE_S,NORMAL);
  808.             set_flag = selection;
  809.             set_object(colorbox,set_flag,SELECTED);
  810.             while(button!=NONE)vq_mouse(handle,&button,&x,&y);
  811.             break;
  812.           }
  813.         switch(selection)
  814.           {
  815.           case SELECT_F:
  816.             set_fill();
  817.             break;
  818.           case SELECT_T:
  819.             set_text();
  820.             break;
  821.           case SELECT_S:
  822.             copy_picture(SHOWN,MASK);
  823.             v_hide_c(handle);
  824.             r[0] = (Getrez() == 0 ? 80 : 160);
  825.             r[1] = (Getrez() == 2 ? 100 : 50);
  826.             r[2] = 2*r[0];
  827.             r[3] = 2*r[1];
  828.             objc_offset(colorbox,SELECT_S,&x,&y);
  829.             w = colorbox[SELECT_S].ob_width;
  830.             h = colorbox[SELECT_S].ob_height;
  831.             form_dial(FMD_GROW,x,y,w,h,r[0],r[1],r[2],r[3]);
  832.             vqf_attributes(handle,attrib);
  833.             vsf_interior(handle,0);
  834.             vsf_style(handle,0);
  835.             temp = r[1]+1;
  836.             r[1] = r[1]+r[3]+1;
  837.             r[2] = r[0]+r[2]+1;
  838.             r[3] = r[3]-temp;
  839.             r[0] = r[0]-1;
  840.             v_rfbox(handle,r);
  841.             select_sprayer();
  842.             vsf_interior(handle,attrib[0]);
  843.             vsf_style(handle,attrib[2]);
  844.             set_object(colorbox,SELECT_S,NORMAL);
  845.             v_show_c(handle,0);
  846.             break;
  847.           case LINE_W:
  848.             set_line();
  849.             break;
  850.           case LINE_S:
  851.             vsl_width(handle,lwidth=1);
  852.             set_line();
  853.             break;
  854.           case COLOR_UP:
  855.             advance_selection(set_flag);
  856.             break;
  857.           case COL_DOWN:
  858.             decrement_selection(set_flag);
  859.             break;
  860.           case R_DOWN:
  861.           case G_DOWN:
  862.           case B_DOWN:
  863.           case R_UP:
  864.           case G_UP:
  865.           case B_UP:
  866.             set_rgb(colorbox,old_pen,selection);
  867.             changed==TRUE;
  868.             for(I=0;I<5;I++)Vsync();
  869.             break;
  870.           case PAL_LOCK:
  871.             if (locked==TRUE)
  872.              {
  873.              ((TEDINFO *) colorbox[PAL_LOCK].ob_spec)->te_ptext=Pal_unlinked;
  874.              locked = FALSE;
  875.              }
  876.             else
  877.              {
  878.              ((TEDINFO *) colorbox[PAL_LOCK].ob_spec)->te_ptext=Pal_linked;
  879.              locked = TRUE;
  880.              }
  881.             ((TEDINFO *) colorbox[PAL_LOCK].ob_spec)->te_txtlen = 17;
  882.             objc_offset(colorbox,PAL_LOCK,&d1,&d2);
  883.             d3 = colorbox[PAL_LOCK].ob_width;
  884.             d4 = colorbox[PAL_LOCK].ob_height;
  885.             objc_draw(colorbox,PAL_LOCK,1,d1,d2,d3,d4);
  886.             while (button != NONE)vq_mouse(handle,&button,&x,&y);
  887.             break;
  888.           case DONE_CB:
  889.             v_hide_c(handle);
  890.             set_object(colorbox,set_flag,NORMAL);
  891.             set_object(colorbox,LINE_S,NORMAL);
  892.             form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  893.             form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  894.             if(locked==TRUE) reset_color(NEW);
  895.             copy_picture(HIDDEN,SHOWN);
  896.             for(I=0;I<15;I++)Vsync();
  897.             while (button != NONE)vq_mouse(handle,&button,&x,&y);
  898.             return;
  899.             break;
  900.           default:
  901.             if(colorbox[selection].ob_width==cw &&
  902.                colorbox[selection].ob_height==ch)
  903.                {
  904.                v_hide_c(handle);
  905.                c= Getrez()==1 ? medmap[a_getpixel(x,y)]:map[a_getpixel(x+2,y)];
  906.                v_show_c(handle,0);
  907.                set_object(colorbox,old_pen,NORMAL);
  908.                set_object(colorbox,selection,CHECKED);
  909.                if(c==1)
  910.                  {
  911.                  set_object(colorbox,selection,NORMAL);
  912.                  set_object(colorbox,selection,DISABLED);
  913.                  }
  914.                if(locked==TRUE && changed==TRUE) reset_color(NEW);
  915.                changed = FALSE;
  916.                old_pen = selection;
  917.                set_rgb(colorbox,old_pen,selection);
  918.                vsf_color(handle,c);
  919.                vst_color(handle,c);
  920.                vsm_color(handle,c);
  921.                vsl_color(handle,c);
  922.                switch(set_flag)
  923.                  {
  924.                  case SELECT_F:
  925.                    set_fill();
  926.                    break;
  927.                  case SELECT_T:
  928.                    set_text();
  929.                    break;
  930.                  case SELECT_S:
  931.                    break;
  932.                  case LINE_W:
  933.                    set_line();
  934.                    break;
  935.                  case LINE_S:
  936.                    set_line();
  937.                    break;
  938.                  }
  939.                while (button != NEITHER) vq_mouse(handle,&button,&x,&y);
  940.                break;
  941.                }
  942.              }
  943.         }
  944.       }
  945.     v_hide_c(handle);
  946.     set_object(colorbox,set_flag,NORMAL);
  947.     set_object(colorbox,LINE_S,NORMAL);
  948.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  949.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  950.     if(locked==TRUE) reset_color(NEW);
  951.     copy_picture(HIDDEN,SHOWN);
  952.     for(I=0;I<15;I++)Vsync();
  953.     while (button != NONE)vq_mouse(handle,&button,&x,&y);
  954.     }
  955.  
  956.  
  957.  
  958.  
  959. show_credits()
  960.     {
  961.     int bx,by,bw,bh,I,x,y,button;
  962.     form_center(credits,&bx,&by,&bw,&bh);
  963.     v_hide_c(handle);
  964.     form_dial(FMD_GROW,0,0,10,10,10,10,30,169);
  965.     form_dial(FMD_GROW,10,169,30,30,work_out[0]-bw,166,bw,32);
  966.     form_dial(FMD_GROW,work_out[0]-bw,166,bw,32,bx,by,bw,bh);
  967.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  968.     objc_draw(credits,0,10,bx,by,bw,bh);
  969.     v_show_c(handle,0);
  970.     for(I=0; I < 30; I++) Vsync();
  971.     vq_mouse(handle,&button,&x,&y);
  972.     while (button == NONE) vq_mouse(handle,&button,&x,&y);
  973.     v_hide_c(handle);
  974.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  975.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  976.     copy_picture(HIDDEN,SHOWN);
  977.     v_show_c(handle,0);
  978.     }
  979.  
  980.  
  981.  
  982.  
  983.  
  984. make_ellipse()
  985.     {
  986.     int p[4],button,I,hold_old,hold_new,II,Ilow,Ihigh;
  987.     hold_old=active_pen;
  988.     for(I=0;I<200;I++) list[I]=0;
  989.     graf_mouse(THIN_CROSS,0);
  990.     v_show_c(handle,0);
  991.     for(;;)
  992.       {
  993.       button=NONE;
  994.       while(button==NONE||button==RIGHT)
  995.          {
  996.          if(check_keyboard(SAVE_S)==TRUE)
  997.            {
  998.            if(locked==FALSE) reset_color(NEW);
  999.            for(I=0;I<200;I++) list[I]=0;
  1000.            set_pen();
  1001.            }
  1002.          vq_mouse(handle,&button,&p[0],&p[1]);
  1003.          p[2]=p[0];
  1004.          p[3]=p[1];
  1005.          }
  1006.       if(button==BOTH) 
  1007.          {
  1008.          if(locked==FALSE)reset_color(NEW);
  1009.          return(TRUE);
  1010.          }
  1011.       if ( rubber_ellipse(p[0],p[1],&p[2],&p[3]) == TRUE)
  1012.         {
  1013.         v_hide_c(handle);
  1014.         v_ellarc(handle,p[0],p[1],p[2]-p[0],p[3]-p[1],0,7200);
  1015.         if(p[1]>p[3])
  1016.           {
  1017.           p[0]=p[1]; /* hold p[1] temporarily */
  1018.           p[1]=p[3];
  1019.           p[3]=p[0];
  1020.           }
  1021.         p[0]=p[3]-p[1];
  1022.         p[1]=p[1]-p[0];
  1023.         if(p[1]<0)p[1]=0;
  1024.         II=(lwidth+1)/(2*(1+Getrez()));
  1025.         if(II>3)II-=1;
  1026.         if(Getrez()==0&&(II<5||II>6))II-=1;
  1027.         Ilow=(p[1]-II < 0 ? 0:p[1]-II);
  1028.         Ihigh=(p[3]+II >199 ? 199:p[3]+II);
  1029.         for(I=Ilow;I<Ihigh+1;I++) list[I]=1;
  1030.         v_show_c(handle,0);
  1031.         }
  1032.       }
  1033.     }
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039. make_box()
  1040.     {
  1041.     int p[4],box_array[10],button,I,hold_old,
  1042.         hold_new,Ilow,Ihigh,II;
  1043.     hold_old=active_pen;
  1044.     for(I=0;I<200;I++) list[I]=0;
  1045.     graf_mouse(THIN_CROSS,0);
  1046.     v_show_c(handle,0);
  1047.     for(;;)
  1048.       {
  1049.       button=NONE;
  1050.       while(button==NONE||button==RIGHT)
  1051.          {
  1052.          if(check_keyboard(SAVE_S)==TRUE)
  1053.            {
  1054.            if(locked==FALSE)reset_color(NEW);
  1055.            for(I=0;I<200;I++) list[I]=0;
  1056.            set_pen();
  1057.            }
  1058.          vq_mouse(handle,&button,&p[0],&p[1]);
  1059.          p[2]=p[0];
  1060.          p[3]=p[1];
  1061.          }
  1062.       if(button==BOTH) 
  1063.          {
  1064.          if(locked==FALSE)reset_color(NEW);
  1065.          return(TRUE);
  1066.          }
  1067.       if ( rubber_box(p[0],p[1],&p[2],&p[3]) == TRUE)
  1068.         {
  1069.         v_hide_c(handle);
  1070.         box_array[0]=box_array[6]=box_array[8]=p[0];
  1071.         box_array[1]=box_array[3]=box_array[9]=p[1];
  1072.         box_array[2]=box_array[4]=p[2];
  1073.         box_array[5]=box_array[7]=p[3];
  1074.         v_pline(handle,5,box_array);
  1075.         if(p[1]>p[3])
  1076.           {
  1077.           p[0]=p[1]; /* hold p[1] temporarily */
  1078.           p[1]=p[3];
  1079.           p[3]=p[0];
  1080.           }
  1081.         II=(lwidth+1)/(2*(1+Getrez()));
  1082.         if(II>3)II-=1;
  1083.         if(Getrez()==0&&(II<5||II>6))II-=1;
  1084.         Ilow=(p[1]-II < 0 ? 0:p[1]-II);
  1085.         Ihigh=(p[3]+II >199 ? 199:p[3]+II);
  1086.         for(I=Ilow;I<Ihigh+1;I++) list[I]=1;
  1087.         v_show_c(handle,0);
  1088.         }
  1089.       }
  1090.     }
  1091.  
  1092.  
  1093.  
  1094.  
  1095. free_hand()
  1096.     {
  1097.     int p[4],button=NONE,I,first,last,hold_old,
  1098.         hold_new,II,Ilow,Ihigh;
  1099.     unsigned form[37];
  1100.     form[0]=2;
  1101.     form[1]=15;
  1102.     form[2]=1;
  1103.     form[3]=0;
  1104.     form[4]=1;
  1105.     stuffbits(&form[5] ,"0000000000000000");
  1106.     stuffbits(&form[6] ,"0000000000001101");
  1107.     stuffbits(&form[7] ,"0000000000011010");
  1108.     stuffbits(&form[8] ,"0000000000110100");
  1109.     stuffbits(&form[9] ,"0000000001101000");
  1110.     stuffbits(&form[10],"0000000011010000");
  1111.     stuffbits(&form[11],"0000000110100000");
  1112.     stuffbits(&form[12],"0000001101000000");
  1113.     stuffbits(&form[13],"0000011010000000");
  1114.     stuffbits(&form[14],"0000110100000000");
  1115.     stuffbits(&form[15],"0001101000000000");
  1116.     stuffbits(&form[16],"0011010000000000");
  1117.     stuffbits(&form[17],"0011100000000000");
  1118.     stuffbits(&form[18],"1111110000000000");
  1119.     stuffbits(&form[19],"1111100000000000");
  1120.     stuffbits(&form[20],"0110000000000000");
  1121.     for(I=21;I<37;I++)form[I]=form[I-16];
  1122.     graf_mouse(255,form);
  1123.     hold_old=active_pen;
  1124.     for(I=0;I<200;I++) list[I]=0;
  1125.     v_show_c(handle,0);
  1126.     vq_mouse(handle,&button,&p[0],&p[1]);
  1127.     while (button != BOTH)
  1128.       {
  1129.       p[0]=p[2];
  1130.       p[1]=p[3];
  1131.       vq_mouse(handle,&button,&p[2],&p[3]);
  1132.       Vsync();
  1133.       if(check_keyboard(SAVE_S)==TRUE)
  1134.         {
  1135.         if(locked==FALSE)reset_color(NEW);
  1136.         for(I=0;I<200;I++) list[I]=0;
  1137.         set_pen();
  1138.         }
  1139.       if(button == LEFT)
  1140.         {
  1141.         v_hide_c(handle);
  1142.         v_pline(handle,2,p);
  1143.         if(p[1]>p[3])
  1144.           {
  1145.           first=p[3];
  1146.           last=p[1];
  1147.           }
  1148.         else
  1149.           {
  1150.           first=p[1];
  1151.           last=p[3];
  1152.           }
  1153.         II=(lwidth+1)/(2*(1+Getrez()));
  1154.         if(II>3)II-=1;
  1155.         if(Getrez()==0&&(II<5||II>6))II-=1;
  1156.         Ilow=(first-II < 0 ? 0:first-II);
  1157.         Ihigh=(last+II >199 ? 199:last+II);
  1158.         for(I=Ilow;I<Ihigh+1;I++) list[I]=1;
  1159.         v_show_c(handle,0);
  1160.         }
  1161.       }
  1162.     if(locked==FALSE)reset_color(NEW);
  1163.     return(TRUE);
  1164.     }
  1165.  
  1166.  
  1167.  
  1168. stippler()
  1169.     {
  1170.     int p[2],rez,button=NONE;
  1171.     int I,r,x,y,x2,y2,climit,rlimit,c;
  1172.     float a,b;
  1173.     unsigned form[37];
  1174.     form[0]=8;
  1175.     form[1]=7;
  1176.     form[2]=1;
  1177.     form[3]=0;
  1178.     form[4]=1;
  1179.     stuffbits(&form[5] ,"0000000000000000");
  1180.     stuffbits(&form[6] ,"0000000000000000");
  1181.     stuffbits(&form[7] ,"0000000000000000");
  1182.     stuffbits(&form[8] ,"0000000000000000");
  1183.     stuffbits(&form[9] ,"0000001110000000");
  1184.     stuffbits(&form[10],"0001100010110000");
  1185.     stuffbits(&form[11],"0110010000101100");
  1186.     stuffbits(&form[12],"1101000100010110");
  1187.     stuffbits(&form[13],"0110010000101100");
  1188.     stuffbits(&form[14],"0001100010110000");
  1189.     stuffbits(&form[15],"0000001110000000");
  1190.     stuffbits(&form[16],"0000000000000000");
  1191.     stuffbits(&form[17],"0000000000000000");
  1192.     stuffbits(&form[18],"0000000000000000");
  1193.     stuffbits(&form[19],"0000000000000000");
  1194.     stuffbits(&form[20],"0000000000000000");
  1195.     for(I=21;I<37;I++)form[I]=form[I-16];
  1196.     graf_mouse(255,form);
  1197.     r=spray_xr*spray_yr;
  1198.     a=(float)spray_yr/(float)spray_xr;
  1199.     b=(float)spray_xr/(float)spray_yr;
  1200.     climit = ( rez==0 ? 320 : 640);
  1201.     rlimit = ( rez==2 ? 400 : 200);
  1202.     while (button != BOTH)
  1203.       {
  1204.       if(check_keyboard(SAVE_S)==TRUE)
  1205.         {
  1206.         r=spray_xr*spray_yr;
  1207.         a=(float)spray_yr/(float)spray_xr;
  1208.         b=(float)spray_xr/(float)spray_yr;
  1209.         }
  1210.       v_show_c(handle,0);
  1211.       vq_mouse(handle,&button,&p[0],&p[1]);
  1212.       if(button==LEFT) v_hide_c(handle);
  1213.       while(button == LEFT)
  1214.         {
  1215.         vq_mouse(handle,&button,&p[0],&p[1]); 
  1216.         
  1217.         do
  1218.           {
  1219.           x=(spray_xr-(abs(rand())%(2*spray_xr+1)));
  1220.           y=(spray_yr-(abs(rand())%(2*spray_yr+1)));
  1221.           } while((int)(x*x*a+y*y*b)>r);
  1222.         do
  1223.           {
  1224.           x2=(spray_xr-(abs(rand())%(2*spray_xr+1)));
  1225.           y2=(spray_yr-(abs(rand())%(2*spray_yr+1)));
  1226.           } while((int)(x2*x2*a+y2*y2*b)>r);
  1227.         x=p[0]+x;
  1228.         y=p[1]+y;
  1229.         x2=p[0]+x2;
  1230.         y2=p[1]+y2;
  1231.         if(x>-1 && x<climit && y>-1 && y<rlimit && x2>-1 && x2<climit 
  1232.           && y2>-1 && y2<rlimit )
  1233.           {
  1234.           c = a_getpixel(x,y);
  1235.           a_putpixel(x,y,a_getpixel(x2,y2));
  1236.           a_putpixel(x2,y2,c);
  1237.           } 
  1238.         }
  1239.       }
  1240.     v_show_c(handle,0);
  1241.     return(TRUE);
  1242.     }
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248. spray_can()
  1249.     {
  1250.     int p[2],rez,button=NONE,hold_old,hold_new,Ilow,Ihigh;
  1251.     int I,x,y,r,climit,rlimit,c,medmap[4],lowmap[16],attrib[10];
  1252.     float a,b;
  1253.     unsigned form[37];
  1254.     hold_old=active_pen;
  1255.     for(I=0;I<200;I++) list[I]=0;
  1256.     form[0]=8;
  1257.     form[1]=3;
  1258.     form[2]=1;
  1259.     form[3]=0;
  1260.     form[4]=1;
  1261.     stuffbits(&form[5] ,"0000001110000000");
  1262.     stuffbits(&form[6] ,"0001100010110000");
  1263.     stuffbits(&form[7] ,"0110010000101100");
  1264.     stuffbits(&form[8] ,"1101010100110110");
  1265.     stuffbits(&form[9] ,"0110001111001100");
  1266.     stuffbits(&form[10],"0001101111010000");
  1267.     stuffbits(&form[11],"0000001110000000");
  1268.     stuffbits(&form[12],"0000000110000000");
  1269.     stuffbits(&form[13],"0001111000110000");
  1270.     stuffbits(&form[14],"0001111000010000");
  1271.     stuffbits(&form[15],"0001111000010000");
  1272.     stuffbits(&form[16],"0001111000010000");
  1273.     stuffbits(&form[17],"0001111000010000");
  1274.     stuffbits(&form[18],"0001111000010000");
  1275.     stuffbits(&form[19],"0001111000010000");
  1276.     stuffbits(&form[20],"0001111111110000");
  1277.     for(I=21;I<37;I++)form[I]=form[I-16];
  1278.     graf_mouse(255,form);
  1279.     a=(float)spray_yr/(float)spray_xr;
  1280.     b=(float)spray_xr/(float)spray_yr;
  1281.     r=spray_xr*spray_yr;
  1282.     medmap[0]=0;
  1283.     medmap[1]=3;
  1284.     medmap[2]=1;
  1285.     medmap[3]=2;
  1286.     lowmap[0]=0;
  1287.     lowmap[1]=15;
  1288.     lowmap[2]=1;
  1289.     lowmap[3]=2;
  1290.     lowmap[4]=4;
  1291.     lowmap[5]=6;
  1292.     lowmap[6]=3;
  1293.     lowmap[7]=5;
  1294.     lowmap[8]=7;
  1295.     lowmap[9]=8;
  1296.     lowmap[10]=9;
  1297.     lowmap[11]=10;
  1298.     lowmap[12]=12;
  1299.     lowmap[13]=14;
  1300.     lowmap[14]=11;
  1301.     lowmap[15]=13;
  1302.     rez = Getrez();
  1303.     vqt_attributes(handle,attrib);
  1304.     c = ( rez ? medmap[attrib[1]] : lowmap[attrib[1]]);
  1305.     climit = ( rez==0 ? 320 : 640);
  1306.     rlimit = ( rez==2 ? 400 : 200);
  1307.     while (button != BOTH)
  1308.       {
  1309.       v_show_c(handle,0);
  1310.       vq_mouse(handle,&button,&p[0],&p[1]);
  1311.       if(check_keyboard(SAVE_S)==TRUE)
  1312.         {
  1313.         if(locked==FALSE)reset_color(NEW);
  1314.         for(I=0;I<200;I++) list[I]=0;
  1315.         set_pen();
  1316.         vqt_attributes(handle,attrib);
  1317.         c = ( rez ? medmap[attrib[1]] : lowmap[attrib[1]]);
  1318.         r=spray_xr*spray_yr;
  1319.         a=(float)spray_yr/(float)spray_xr;
  1320.         b=(float)spray_xr/(float)spray_yr;
  1321.         }
  1322.       if(button==LEFT) v_hide_c(handle);
  1323.       while(button == LEFT)
  1324.         {
  1325.         vq_mouse(handle,&button,&p[0],&p[1]);
  1326.         Ilow=(p[1]-spray_yr<0 ? 0 : p[1]-spray_yr);
  1327.         Ihigh=(p[1]+spray_yr>200 ? 200 : p[1]+spray_yr+1);
  1328.         for(I=Ilow;I<Ihigh;I++)list[I]=1;
  1329.         do
  1330.           {
  1331.           x=spray_xr-(abs(rand())%(2*spray_xr+1));
  1332.           y=spray_yr-(abs(rand())%(2*spray_yr+1));
  1333.           } while((x*x*a+y*y*b)>r);
  1334.         p[0]=p[0]+x;
  1335.         p[1]=p[1]+y;
  1336.         if(p[0] > -1 && p[0] < climit && p[1] > -1 && p[1]< rlimit )
  1337.           a_putpixel(p[0],p[1],c); 
  1338.         }
  1339.       }
  1340.     v_show_c(handle,0);
  1341.     if(locked==FALSE)reset_color(NEW);
  1342.     return(TRUE);
  1343.     }
  1344.  
  1345.  
  1346.  
  1347.  
  1348. linefan()
  1349.     {
  1350.     int p[6],button,x,y,test=0,I,flag,first,
  1351.         last,hold_old,hold_new,II,Ilow,Ihigh;
  1352.     hold_old=active_pen;
  1353.     for(I=0;I<200;I++) list[I]=0;
  1354.     last=0;
  1355.     first=200;
  1356.     flag=0;
  1357.     graf_mouse(OUTLN_CROSS,0);
  1358.     v_show_c(handle,0);
  1359.     for(;;)
  1360.       {
  1361.       vq_mouse(handle,&button,&x,&y);
  1362.       if(check_keyboard(SAVE_S)==TRUE)
  1363.         {
  1364.         if(locked==FALSE)reset_color(NEW);
  1365.         for(I=0;I<200;I++) list[I]=0;
  1366.         set_pen();
  1367.         }
  1368.       switch ( button )
  1369.         {
  1370.         case RIGHT:            /*** Set New Starting Point  ***/
  1371.           p[0]=p[4]=x;
  1372.           p[1]=p[5]=y;
  1373.           test=1;
  1374.             break;
  1375.         case LEFT:             /*** Draw A Line To This New ***/
  1376.           p[2]=x;              /*** Ending Point.           ***/
  1377.           p[3]=y;
  1378.           if(test==0)
  1379.             {
  1380.             test=1;            /*** Set initial starting point ***/
  1381.             p[0]=p[4]=x;
  1382.             p[1]=p[5]=y;
  1383.             }
  1384.           flag=1;
  1385.           if(p[1]<first) first=p[1];
  1386.             if(p[3]<first) first=p[3];
  1387.           if(p[1]>last) last=p[1];
  1388.           if(p[3]>last) last=p[3];
  1389.           v_hide_c(handle);
  1390.           v_pline(handle,3,p); 
  1391.           v_show_c(handle,0);
  1392.           break;
  1393.         case NEITHER:
  1394.           if(flag==1)
  1395.             {
  1396.             II=(lwidth+1)/(2*(1+Getrez()));
  1397.             if(II>3)II-=1;
  1398.             if(Getrez()==0&&(II<5||II>6))II-=1;
  1399.               Ilow=(first-II < 0 ? 0:first-II);
  1400.             Ihigh=(last+II >199 ? 199:last+II);
  1401.             for(I=Ilow;I<Ihigh+1;I++) list[I]=1;
  1402.             last=0;
  1403.             first=200;
  1404.             flag=0;
  1405.             }
  1406.           break;
  1407.         case BOTH:
  1408.           if(locked==FALSE)reset_color(NEW);
  1409.           return(TRUE);
  1410.           break;
  1411.         }
  1412.       }
  1413.     }
  1414.  
  1415.  
  1416.  
  1417. edit_text()
  1418.     {
  1419.     int I,x,y,button;
  1420.     char text[81];
  1421.     for(I=0;I<81;I++) text[I]='\0';
  1422.     graf_mouse(TEXT_CRSR,0);
  1423.     vswr_mode(handle,3);
  1424.     v_show_c(handle,0);
  1425.     for(;;)
  1426.       {
  1427.       button=NONE;
  1428.       I=0;
  1429.       while(button==NONE)
  1430.         {
  1431.         vq_mouse(handle,&button,&x,&y);
  1432.         if(Bconstat(2)!=FALSE) 
  1433.           {
  1434.           text[I++] = (char)(Bconin(2)&127);
  1435.           if((int)text[I-1]==8 || (int)text[I-1]==127)
  1436.             {
  1437.             text[--I] = '\0';
  1438.             text[--I] = '\0';
  1439.             }
  1440.           if( (int)text[I-1]==0 ) text[--I] = '\0';
  1441.           if ( I >80 ) I=80;
  1442.           }
  1443.         if ( I >0 )
  1444.           {
  1445.           v_hide_c(handle);
  1446.           v_gtext(handle,x,y,text);
  1447.           Vsync();
  1448.           Vsync();
  1449.           Vsync();
  1450.           v_gtext(handle,x,y,text);
  1451.           Vsync();
  1452.           }
  1453.         }
  1454.       switch(button) 
  1455.         {
  1456.         case BOTH:
  1457.            vswr_mode(handle,linewmode);
  1458.            return(TRUE);
  1459.            break;
  1460.         case LEFT:
  1461.            v_hide_c(handle);
  1462.            vswr_mode(handle,textwmode);
  1463.            v_gtext(handle,x,y,text);
  1464.            for(I=0;I<81;I++) text[I]='\0';
  1465.            vswr_mode(handle,3);
  1466.            v_show_c(handle,0);
  1467.            break;
  1468.         case RIGHT:
  1469.            for(I=0;I<81;I++) text[I]='\0';
  1470.            v_show_c(handle,0);
  1471.            break;
  1472.         }
  1473.       v_show_c(handle,0);
  1474.       }
  1475.     }
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481. fill_it()
  1482.     {
  1483.     int p[4],button,I;
  1484.     unsigned form[37];
  1485.     form[0]=15;
  1486.     form[1]=15;
  1487.     form[2]=1;
  1488.     form[3]=1;
  1489.     form[4]=1;
  1490.     stuffbits(&form[5] ,"0000000000000000");
  1491.     stuffbits(&form[6] ,"0000000000000000");
  1492.     stuffbits(&form[7] ,"0000000000000000");
  1493.     stuffbits(&form[8] ,"0000000100000000");
  1494.     stuffbits(&form[9] ,"0000000100000000");
  1495.     stuffbits(&form[10],"0000010100000000");
  1496.     stuffbits(&form[11],"0000100100000000");
  1497.     stuffbits(&form[12],"0001000101000000");
  1498.     stuffbits(&form[13],"0010000100010000");
  1499.     stuffbits(&form[14],"0100000100000100");
  1500.     stuffbits(&form[15],"1000000000001000");
  1501.     stuffbits(&form[16],"0010000000010010");
  1502.     stuffbits(&form[17],"0000100000100000");
  1503.     stuffbits(&form[18],"0000001001000010");
  1504.     stuffbits(&form[19],"0000000010000110");
  1505.     stuffbits(&form[20],"0000000000000000");
  1506.     stuffbits(&form[21],"0000000000000000");
  1507.     stuffbits(&form[22],"0000000000000000");
  1508.     stuffbits(&form[23],"0000000000000000");
  1509.     stuffbits(&form[24],"0000000100000000");
  1510.     stuffbits(&form[25],"0000000100000000");
  1511.     stuffbits(&form[26],"0000010100000000");
  1512.     stuffbits(&form[27],"0000111100000000");
  1513.     stuffbits(&form[28],"0001100101000000");
  1514.     stuffbits(&form[29],"0011000100010000");
  1515.     stuffbits(&form[30],"0110000110001100");
  1516.     stuffbits(&form[31],"1111111111111000");
  1517.     stuffbits(&form[32],"0011111111110010");
  1518.     stuffbits(&form[33],"0000111111100000");
  1519.     stuffbits(&form[34],"0000001111000010");
  1520.     stuffbits(&form[35],"0000000010000110");
  1521.     stuffbits(&form[36],"0000000000000000");
  1522.     graf_mouse(255,form);
  1523.     v_show_c(handle,0);
  1524.     for(;;)
  1525.       {
  1526.       button=NONE;
  1527.       while(button==NONE||button==RIGHT)
  1528.         {
  1529.         vq_mouse(handle,&button,&p[0],&p[1]);
  1530.         check_keyboard(SAVE_S);
  1531.         }
  1532.       if(button==BOTH) return(TRUE);
  1533.       v_hide_c(handle);
  1534.       v_contourfill(handle,p[0],p[1],-1);
  1535.       v_show_c(handle,0);
  1536.       }
  1537.     }
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543. flip_vertical()
  1544.     {
  1545.     int I,J,temp;
  1546.     v_hide_c(handle);
  1547.     for(I=0; I<200; I++)
  1548.       for(J=0; J<40; J++)
  1549.         *((long*)SHOWN+I*40+J) = *((long*)HIDDEN+(199-I)*40+J);
  1550.     for(I=0;I<100;I++)
  1551.       for(J=0;J<16;J++)
  1552.         {                              /* flip colors too! */
  1553.         temp = cb_pal[KEY][J+I*16];
  1554.         cb_pal[KEY][J+I*16] = cb_pal[KEY][J+(199-I)*16];
  1555.         cb_pal[KEY][J+(199-I)*16] = temp;
  1556.         }
  1557.     stuff_current_cbpal(NEW);
  1558.     v_show_c(handle,0);
  1559.     }
  1560.  
  1561.  
  1562. flip_horizontal()
  1563.     {
  1564.     register int I,J,K;
  1565.     register unsigned int ying,*shown,*hidden;
  1566.     int unit,limit,rez;
  1567.     shown = (unsigned int*)SHOWN;
  1568.     hidden = (unsigned int*)HIDDEN;
  1569.     v_hide_c(handle);
  1570.     rez = Getrez();
  1571.     unit = (rez == 0 ? 4 : (2/rez) );
  1572.     limit = (rez == 2 ? 400 : 200);
  1573.     for(I=0; I<limit; I++)
  1574.      for(J=0; J<80; J += unit)
  1575.       for(K=0; K<unit; K++) 
  1576.        {
  1577.        ying = *(hidden+(I+1)*80-unit-J+K);
  1578.        *(shown+I*80+J+K) = ((ying & 1) << 15) + 
  1579.        ((ying & 2) << 13) + ((ying & 4) << 11) + ((ying & 8) << 9) + 
  1580.        ((ying & 16) << 7) + ((ying & 32) << 5) + ((ying & 64) << 3) + 
  1581.        ((ying & 128) << 1) + ((ying & 256) >> 1) + ((ying & 512) >> 3) + 
  1582.        ((ying & 1024) >>5) + ((ying & 2048) >>7) + ((ying & 4096) >>9) +
  1583.        ((ying & 8192)>>11) + ((ying & 16384)>>13) + ((ying & 32768)>>15);
  1584.        }
  1585.     v_show_c(handle,0);
  1586.     }
  1587.  
  1588.  
  1589.  
  1590. quarter_screen()
  1591.     {
  1592.     register int I,J,dots_per_row;
  1593.     register long *shown;
  1594.     int unit,limit,rez;
  1595.     v_hide_c(handle);
  1596.     shown = (long*)SHOWN;
  1597.     rez = Getrez();
  1598.     limit = (rez == 2 ? 400 : 200);
  1599.     dots_per_row = (rez == 0 ? 320 : 640);
  1600.     for(I=0; I<limit; I+=2)
  1601.      for(J=0;J<dots_per_row;J+=2)
  1602.       {
  1603.       a_putpixel(J/2,I/2,a_getpixel(J,I));
  1604.       }
  1605.     for(I=4000;I<8000;I++) *(shown+I)=0L;
  1606.     for(I=0;I<4000;I+=8000/limit)
  1607.      for(J=4000/limit;J<8000/limit;J++)
  1608.       *(shown+I+J)=0L;
  1609.     for(I=0;I<3200;I+=32)
  1610.      for(J=0;J<16;J++)
  1611.       {
  1612.       cb_pal[KEY][I/2+J]=cb_pal[KEY][I+J];
  1613.       }
  1614.     stuff_current_cbpal(OLD);
  1615.     v_show_c(handle,0);
  1616.     }
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622. check_keyboard(flag)
  1623.     int flag;
  1624.     {
  1625.     char c;
  1626.     if( Bconstat(2) == FALSE ) return(FALSE);
  1627.     c = (char)(Bconin(2)&127);
  1628.     if( c=='c' || c=='C' || c=='s' || c=='S' || c=='e' || c=='E')
  1629.       {
  1630.       switch (flag)
  1631.         {
  1632.         case SAVE_S:
  1633.              copy_picture(SHOWN,HIDDEN);
  1634.              break;
  1635.         case SAVE_Z:
  1636.              copy_picture(SHOWN,MASK);
  1637.              set_pen();
  1638.              copy_picture(MASK,SHOWN);
  1639.              break;
  1640.         }
  1641.       return(TRUE);
  1642.       }
  1643.     return(FALSE);
  1644.     }
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650. clear_screen(destination)
  1651.     register long *destination;
  1652.     {
  1653.     register int N;
  1654.     v_hide_c(handle);
  1655.     for(N=0;(N++)<8000;*(destination++)=0L);
  1656.     v_show_c(handle,0);
  1657.     }
  1658.  
  1659.  
  1660. copy_picture(source,destination)
  1661.     register long *source,*destination;
  1662.     {
  1663.     register int N;
  1664.     v_hide_c(handle);
  1665.     for(N=0;(N++)<8000;*(destination++)=*(source++));
  1666.     v_show_c(handle,0);
  1667.     }
  1668.  
  1669.  
  1670.  
  1671.  
  1672. zoom_edit()
  1673.     {
  1674.     int I,p[4],button=NONE;
  1675.     v_hide_c(handle);
  1676.     graf_mouse(POINT_HAND,0);
  1677.     while(button != NONE) vq_mouse(handle,&button,&p[2],&p[3]);
  1678.     while (button != BOTH)
  1679.         {
  1680.         vq_mouse(handle,&button,&p[2],&p[3]);
  1681.         if(check_keyboard(FALSE)==TRUE) 
  1682.           {
  1683.           set_pen();
  1684.           zoom_it(p[0],p[1]);
  1685.           }
  1686.         if(button == NONE)
  1687.             {
  1688.             copy_picture(HIDDEN,SHOWN);
  1689.             v_hide_c(handle);
  1690.             while(button ==  NONE)
  1691.               {
  1692.               p[0]=p[2];
  1693.               p[1]=p[3];
  1694.               vq_mouse(handle,&button,&p[2],&p[3]);
  1695.               graf_movebox((work_out[0]+1)/10,25,p[2],p[3],p[2],p[3]);
  1696.               }
  1697.             if(button == LEFT) zoom_it(p[2],p[3]);
  1698.             v_show_c(handle,0);
  1699.             }
  1700.         }
  1701.     copy_picture(HIDDEN,SHOWN);
  1702.     return(TRUE);
  1703.     }
  1704.  
  1705.  
  1706.  
  1707. zoom_it(x,y)
  1708.     int x,y;
  1709.     {
  1710.     int I,k,c,xmax;
  1711.     copy_picture(HIDDEN,SHOWN);
  1712.     v_hide_c(handle);
  1713.     xmax = (work_out[0]+1)/10;
  1714.     if( x > (work_out[0])*9/10 ) x = (work_out[0])*9/10;
  1715.     if( y > 174 ) y = 174;
  1716.     for(I=0;I< xmax;I++)
  1717.       {
  1718.       for(k=0;k<25;k++)
  1719.         {
  1720.         Setscreen(HIDDEN,SHOWN,-1);
  1721.         c = a_getpixel(x+I,y+k);
  1722.         Setscreen(SHOWN,SHOWN,-1);
  1723.         a_putpixel(I*3,k*3,c);
  1724.         a_putpixel(I*3+1,k*3,c);
  1725.         a_putpixel(I*3+2,k*3,c);
  1726.         a_putpixel(I*3,k*3+1,c);
  1727.         a_putpixel(I*3+1,k*3+1,c);
  1728.         a_putpixel(I*3+2,k*3+1,c);
  1729.         a_putpixel(I*3,k*3+2,c);
  1730.         a_putpixel(I*3+1,k*3+2,c);
  1731.         a_putpixel(I*3+2,k*3+2,c);
  1732.         }
  1733.       }
  1734.     Setscreen(SHOWN,SHOWN,-1);
  1735.     v_show_c(handle,0);
  1736.     if(edit_zoom(x,y)==FALSE) zoom_it(x,y);
  1737.     copy_picture(HIDDEN,SHOWN);
  1738.     }
  1739.  
  1740.  
  1741.  
  1742.  
  1743. edit_zoom(x0,y0)
  1744.     int x0,y0;
  1745.     {
  1746.     int x,y,I,button,c,medmap[4],lowmap[16];
  1747.     int attrib[10];
  1748.     medmap[0]=0;
  1749.     medmap[1]=3;
  1750.     medmap[2]=1;
  1751.     medmap[3]=2;
  1752.     lowmap[0]=0;
  1753.     lowmap[1]=15;
  1754.     lowmap[2]=1;
  1755.     lowmap[3]=2;
  1756.     lowmap[4]=4;
  1757.     lowmap[5]=6;
  1758.     lowmap[6]=3;
  1759.     lowmap[7]=5;
  1760.     lowmap[8]=7;
  1761.     lowmap[9]=8;
  1762.     lowmap[10]=9;
  1763.     lowmap[11]=10;
  1764.     lowmap[12]=12;
  1765.     lowmap[13]=14;
  1766.     lowmap[14]=11;
  1767.     lowmap[15]=13;
  1768.     vq_mouse(handle,&button,&x,&y);
  1769.     while(button != RIGHT )
  1770.       {
  1771.       check_keyboard(SAVE_Z);
  1772.       vqt_attributes(handle,attrib);
  1773.       c = (Getrez() ? medmap[attrib[1]] : lowmap[attrib[1]]);
  1774.       vq_mouse(handle,&button,&x,&y);
  1775.       if(button == LEFT)
  1776.         {
  1777.         if(x>(work_out[0]+1)*3/10 || y>75)
  1778.           {
  1779.           RING_BELL();
  1780.           }
  1781.         else
  1782.           {
  1783.           x=x/3;
  1784.           y=y/3;
  1785.           v_hide_c(handle);
  1786.           Setscreen(HIDDEN,SHOWN,-1);
  1787.           a_putpixel(x0+x,y0+y,c);
  1788.           Setscreen(SHOWN,SHOWN,-1);
  1789.           if((x0+x)>(work_out[0]+1)*3/10||(y0+y)>75) a_putpixel(x0+x,y0+y,c);
  1790.           a_putpixel(x*3,y*3,c);
  1791.           a_putpixel(x*3+1,y*3,c);
  1792.           a_putpixel(x*3+2,y*3,c);
  1793.           a_putpixel(x*3,y*3+1,c);
  1794.           a_putpixel(x*3+1,y*3+1,c);
  1795.           a_putpixel(x*3+2,y*3+1,c);
  1796.           a_putpixel(x*3,y*3+2,c);
  1797.           a_putpixel(x*3+1,y*3+2,c);
  1798.           a_putpixel(x*3+2,y*3+2,c);
  1799.           v_show_c(handle,0);
  1800.           }
  1801.         }
  1802.       }
  1803.     return(TRUE);
  1804.     }
  1805.  
  1806.  
  1807.  
  1808.  
  1809. shadow_text(X,Y,text,color,mode)
  1810.     int X,Y,color,mode;
  1811.     char text[40];
  1812.     {
  1813.     int attrib[10],d;
  1814.     vqt_attributes(handle,attrib);
  1815.     vst_height(handle,6,&d,&d,&d,&d);
  1816.     v_hide_c(handle);
  1817.     vswr_mode(handle,mode);       /* SET WRITE MODE    */
  1818.     vst_color(handle,0);          /* SHADOW COLOR=0    */
  1819.     v_gtext(handle,X+2,Y+1,text);
  1820.     vst_color(handle,color);
  1821.     v_gtext(handle,X,Y,text);
  1822.     vst_color(handle,attrib[1]);  /* RESET OLD COLOR   */
  1823.     vswr_mode(handle,attrib[5]);  /* RESET OLD MODE    */
  1824.     vst_height(handle,text_h,&d,&d,&d,&d);
  1825.     v_show_c(handle,1);
  1826.     }
  1827.  
  1828.  
  1829. trade_buffers(key,bx,by,bw,bh)
  1830.     int key,bx,by,bw,bh;
  1831.     {
  1832.     int I;
  1833.     char s[90];
  1834.     key = (key/0x100)-0x003B;
  1835.     if(key <= max_num_screens)
  1836.       {
  1837.       form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  1838.       form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  1839.       HIDDEN = SCREEN[key];
  1840.       KEY = key;
  1841.       copy_picture(HIDDEN,SHOWN);
  1842.       stuff_current_cbpal(NEW);
  1843.       sprintf(s,"[0][ | Current screen  | set to Screen(%d)   | ][ok]",key+1);
  1844.       form_alert(1,s);
  1845.       return(TRUE);
  1846.       }
  1847.     else
  1848.       {
  1849.       sprintf(s,"[1][ | Screen(%d) is not | available. | \
  1850. Last screen is %d   ][ Whoops ]",key+1,max_num_screens+1);
  1851.       form_alert(1,s);
  1852.       return(NO_REDRAW);
  1853.       }
  1854.     }
  1855.  
  1856.  
  1857.  
  1858. stuff_current_cbpal(flag)
  1859.     int flag;
  1860.     {
  1861.     register int I,J,tempr,tempg,tempb;
  1862.     int temp;
  1863.     for(I=0;I<200;I++)             /* For STe use bits from 4th byte to */
  1864.     for(J=0;J<16;J++)              /* extend color range up to 30 (32)  */
  1865.       {
  1866.       tempr = ((cb_pal[KEY][I*16+J] & 0x4000) >0 ? (0x1000+(cb_pal[KEY][I*16+J]
  1867.               & 0xf00)) : (cb_pal[KEY][I*16+J] & 0xf00));
  1868.       tempg = ((cb_pal[KEY][I*16+J] & 0x2000) >0 ? (0x0100+(cb_pal[KEY][I*16+J]
  1869.               & 0x0f0)) : (cb_pal[KEY][I*16+J] & 0x0f0));
  1870.       tempb = ((cb_pal[KEY][I*16+J] & 0x1000) >0 ? (0x0010+(cb_pal[KEY][I*16+J]
  1871.               & 0x00f)) : (cb_pal[KEY][I*16+J] & 0x00f));
  1872.       cb1_palette[I*16+J] = 0x100 * STe_rgb[((tempr/2)&0xf00)/0x100]
  1873.                           + 0x010 * STe_rgb[((tempg/2)&0x0f0)/0x010] 
  1874.                           + STe_rgb[((tempb/2)&0x00f)];
  1875.       cb2_palette[I*16+J] = 0x100 * STe_rgb[(((0x100+tempr)/2)&0xf00)/0x100]
  1876.                           + 0x010 * STe_rgb[(((0x010+tempg)/2)&0x0f0)/0x010] 
  1877.                           + STe_rgb[(((1+tempb)/2)&0x00f)];
  1878.       if((I%2)==1) 
  1879.         {                /* Swap definitions on odd lines */
  1880.         temp=cb2_palette[I*16+J];
  1881.         cb2_palette[I*16+J] = cb1_palette[I*16+J] ;
  1882.         cb1_palette[I*16+J] = temp;
  1883.         }
  1884.       }
  1885.     if (flag == NEW)
  1886.       {
  1887.       for(J=0;J<16;J++) 
  1888.         {
  1889.         tempr = ((cb_pal[KEY][J] & 0x4000) >0 ? (0x1000+(cb_pal[KEY][J]
  1890.                 & 0xf00)) : (cb_pal[KEY][J] & 0xf00));
  1891.         tempg = ((cb_pal[KEY][J] & 0x2000) >0 ? (0x0100+(cb_pal[KEY][J]
  1892.                 & 0x0f0)) : (cb_pal[KEY][J] & 0x0f0));
  1893.         tempb = ((cb_pal[KEY][J] & 0x1000) >0 ? (0x0010+(cb_pal[KEY][J]
  1894.                 & 0x00f)) : (cb_pal[KEY][J] & 0x00f));
  1895.         I = 0x100 * ((((0x100+tempr)/2)&0xf00)/0x100) + 0x010 * 
  1896.             ((((0x010+tempg)/2)&0x0f0)/0x010) + (((1+tempb)/2)&0x00f);
  1897.         palette[J] = I;
  1898.         pic_palette[KEY][J] = cb_pal[KEY][J];
  1899.         }
  1900.       Setpal(palette);
  1901.     }
  1902.     }
  1903.  
  1904.  
  1905.  
  1906.  
  1907. edit()
  1908.      {
  1909.      int p[4],button,I,temp;
  1910.     copy_picture(HIDDEN,SHOWN);
  1911.     graf_mouse(THIN_CROSS,0);
  1912.     vq_mouse(handle,&button,&p[0],&p[1]);
  1913.     while( button != LEFT)    vq_mouse(handle,&button,&p[0],&p[1]);
  1914.     if ( rubber_box(p[0],p[1],&p[2],&p[3]) == TRUE)
  1915.       {
  1916.       if(p[2]<p[0]) 
  1917.         {
  1918.         temp=p[0];
  1919.         p[0]=p[2];
  1920.         p[2]=temp;
  1921.         }
  1922.       if(p[3]<p[1]) 
  1923.         {
  1924.         temp=p[1];
  1925.         p[1]=p[3];
  1926.         p[3]=temp;
  1927.         }
  1928.       p[2]=p[2]-p[0];
  1929.       p[3]=p[3]-p[1];
  1930.       clear_screen(SPRITE);
  1931.       cut_sprite(HIDDEN,SPRITE,p);
  1932.       copy_picture(SPRITE,SHOWN);
  1933.       for(I=0;I<75;I++)Vsync();
  1934.       copy_picture(HIDDEN,SHOWN);
  1935.       graf_mouse(ARROW,0);
  1936.       return(TRUE);
  1937.       }
  1938.     return(FALSE);
  1939.      }
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945. cut_sprite(s_address,d_address,p)
  1946.     long s_address,d_address;
  1947.     int p[4];
  1948.     {
  1949.     int J,I,sfdb[10],dfdb[10],xy[8];
  1950.     long *temp1,*temp2;
  1951.         /***** Set Memory Form Definition Blocks *****/
  1952.     J = (( I=Getrez() ) == 0 ) ? 4 : 2 ;
  1953.     temp1 = (long *) &sfdb[0];
  1954.     temp2 = (long *) &dfdb[0];
  1955.     sfdb[2] = dfdb[2] = work_out[0]+1;
  1956.     sfdb[3] = dfdb[3] = work_out[1]+1;
  1957.     sfdb[4] = dfdb[4] = ( work_out[0]+1)/16;
  1958.     sfdb[5] = dfdb[5] = 0;
  1959.     sfdb[6] = dfdb[6] = J;
  1960.     xy[0]=p[0];
  1961.     xy[1]=p[1];
  1962.     width=xy[6]=p[2];
  1963.     height=xy[7]=p[3];
  1964.     xy[2]=p[0]+p[2];
  1965.     xy[3]=p[1]+p[3];
  1966.     xy[4]=xy[5]=0;
  1967.     *temp1 = s_address;
  1968.     *temp2 = d_address;
  1969.     vro_cpyfm(handle,3,xy,sfdb,dfdb);
  1970.     }
  1971.  
  1972.  
  1973.  
  1974.  
  1975. paste_sprite()
  1976.      {
  1977.      if (height == 0) return(FALSE);
  1978.     copy_picture(HIDDEN,SHOWN);
  1979.     move_sprite();
  1980.     copy_picture(SHOWN,HIDDEN);  /* SAVE FOR FUTURE GENERATIONS */
  1981.     return(TRUE);
  1982.      }
  1983.  
  1984.  
  1985.  
  1986. move_sprite()
  1987.     {
  1988.     int sfdb[12],dfdb[10],xy[8],planes,but,x,y;
  1989.     long *temp1,*temp2;
  1990.         /***** Set Memory Form Definition Blocks *****/
  1991.     planes = 4-2*Getrez();
  1992.     temp1 = (long *) &sfdb[0];
  1993.     temp2 = (long *) &dfdb[0];
  1994.     sfdb[2] = dfdb[2] = work_out[0]+1;
  1995.     sfdb[3] = dfdb[3] = work_out[1]+1;
  1996.     sfdb[4] = dfdb[4] = ( work_out[0]+1)/16;
  1997.     sfdb[5] = dfdb[5] = 0;
  1998.     sfdb[6] = dfdb[6] = planes;
  1999.     but = NONE;
  2000.     copy_picture(HIDDEN,SHOWN);
  2001.     v_hide_c(handle);
  2002.     while( but != LEFT && but != RIGHT)
  2003.      {
  2004.      vq_mouse(handle,&but,&xy[4],&xy[5]);
  2005.      if( x != xy[4] || y != xy[5] )
  2006.        {
  2007.        xy[0] = xy[4] = x;
  2008.        xy[1] = xy[5] = y;
  2009.        xy[2] = xy[6] = x + width;
  2010.        xy[3] = xy[7] = y + height;
  2011.        *temp1 = HIDDEN;
  2012.        *temp2 = SHOWN;
  2013.        Setscreen(HIDDEN,HIDDEN,-1);
  2014.        Vsync();
  2015.        vro_cpyfm(handle,3,xy,sfdb,dfdb);
  2016.        vq_mouse(handle,&but,&xy[4],&xy[5]);
  2017.        *temp1 = SPRITE;
  2018.        *temp2 = SHOWN;
  2019.        xy[0] = xy[1] = 0;
  2020.        xy[2] = width;
  2021.        xy[3] = height;
  2022.        if (xy[4] > work_out[0]-width ) xy[4] = work_out[0] - width;
  2023.        if (xy[5] > work_out[1]-height )xy[5] = work_out[1] - height;
  2024.        xy[6] = xy[4] + width;
  2025.        xy[7] = xy[5] + height;
  2026.        vro_cpyfm(handle,3,xy,sfdb,dfdb);
  2027.        Setscreen(SHOWN,SHOWN,-1);
  2028.        Vsync();
  2029.        }
  2030.      x=xy[4];
  2031.      y=xy[5];
  2032.      }
  2033.     if (but == RIGHT) copy_picture(HIDDEN,SHOWN);
  2034.     return(TRUE);
  2035.     }
  2036.  
  2037.  
  2038.  
  2039. select_picture(type,size,off)
  2040.     int type;
  2041.     unsigned *size;
  2042.     long off[2];
  2043.     {
  2044.     static char    neo_alert_text[] =
  2045. "[1][ Neochrome works |only in LOW resolution]\
  2046. [ ABORT|continue ]";
  2047.     *size=32;
  2048.     switch(type)
  2049.       {
  2050.       case NEO:
  2051.       case S_NEO:
  2052.         if(Getrez() != LOW)
  2053.             {
  2054.            if (form_alert(1,neo_alert_text)==1) return (FALSE);
  2055.            }
  2056.         off[0]=4L;
  2057.         off[1]=128L;
  2058.         if(chose_a_file("*.NEO",type)==FALSE)return(FALSE);
  2059.         break;
  2060.       case DEGAS:
  2061.       case S_DEGAS:
  2062.         off[0]=2L;
  2063.         off[1]=34L;
  2064.         switch(Getrez())
  2065.           {
  2066.           case LOW:
  2067.             if(chose_a_file("*.PI1",type)==FALSE)return(FALSE);
  2068.             break;
  2069.           case MEDIUM:
  2070.             if(chose_a_file("*.PI2",type)==FALSE)return(FALSE);
  2071.             break;
  2072.           }
  2073.         break;
  2074.       case PICTURES:
  2075.       case PICTUREL:
  2076.         off[0] = 0L;
  2077.         off[1] = 6400L;
  2078.         *size = 6400;
  2079.         if(chose_a_file("*.BST",type)==FALSE)return(FALSE);
  2080.         break;
  2081.       }
  2082.     return(TRUE);
  2083.     }
  2084.  
  2085.  
  2086.  
  2087. chose_a_file(path,purpose)
  2088.     char *path;
  2089.     int purpose;
  2090.     {
  2091.     int I,J,response;
  2092.     char directory[20],name[20];
  2093.     if (purpose==PICTUREL||purpose==NEO||purpose==DEGAS)
  2094.     shadow_text(((work_out[0]/3)-7),22," Load which file ?",2,TRANSPARENT);
  2095.     else if (purpose==PICTURES)
  2096.     shadow_text(((work_out[0]/3)-7),22," Save file as :",2,TRANSPARENT);
  2097.     else if (purpose==PROGRAM)
  2098.     shadow_text(((work_out[0]/3)-7),22," Run which file ?",2,TRANSPARENT);
  2099.     directory[0] = default_drive;
  2100.     directory[1] = ':' ;
  2101.     strcpy(&directory[2],path);
  2102.     strcpy(name,path);
  2103.     for(I=0;I<40;filename[I++]='\0');  /*** Removes Junk characters ***/
  2104.     fsel_input(directory,name,&response);
  2105.     if(response==FALSE) return(FALSE);
  2106.     default_drive = directory[0];  /* Come Back To Last Directory */
  2107.     for(I=0;directory[I]!='*';filename[I++]=directory[I]);
  2108.     for(J=0;name[J]!='\0';filename[I++]=name[J++]);
  2109.     copy_picture(HIDDEN,SHOWN);
  2110.     shadow_text(((work_out[0]/3)-7),22,filename,2,TRANSPARENT);
  2111.     return(TRUE);
  2112.     }
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119. load_picture(size,off)
  2120.     unsigned size;
  2121.     long off[2];
  2122.     {
  2123.     int filehandle,I,K,J,good,r,g,b,t;
  2124.     unsigned filesize;
  2125.     filehandle=open(filename,O_BINARY);
  2126.     if (filehandle==-1)
  2127.        {
  2128.        form_alert(1,"[1][ | Error opening file.     |    ][CANCEL]");
  2129.        return(FALSE);
  2130.        }
  2131.     v_hide_c(handle);
  2132.     lseek(filehandle,off[0],0);        /* Skip header & load palette */
  2133.     if(size == 32)                  /* Neo and Degas              */
  2134.       {
  2135.       good = read(filehandle,pic_palette[KEY],size);
  2136.       if (good == -1)
  2137.        {
  2138.        form_alert(1,"[1][ | Error loading palette.   |    ][CANCEL]");
  2139.        return(FALSE);
  2140.        }
  2141.       for(I=0;I<3200;I++)  /* deal with a Neo or Degas STe upgrade now */
  2142.         {
  2143.         t = 0xf00 & pic_palette[KEY][I%16];
  2144.         r = ( t > 0x700 ? 0x4000+2*(t-0x800) : 2*t );
  2145.         t = 0x0f0 & pic_palette[KEY][I%16];
  2146.         g = ( t > 0x070 ? 0x2000+2*(t-0x080) : 2*t );
  2147.         t = 0x00f & pic_palette[KEY][I%16];
  2148.         b = ( t > 0x007 ? 0x1000+2*(t-0x008) : 2*t );
  2149.         cb_pal[KEY][I] = r+g+b;
  2150.         }
  2151.       stuff_current_cbpal(NEW);
  2152.       }
  2153.     else                            /* ColorBurst II              */
  2154.       {
  2155.       read(filehandle,cb_pal[KEY],size);
  2156.       if (good == -1)
  2157.        {
  2158.        form_alert(1,"[1][ | Error loading palette.   |    ][CANCEL]");
  2159.        return(FALSE);
  2160.        }
  2161.       }
  2162.     lseek(filehandle,off[1],0);    /*  Load screen  offset       */
  2163.     if(size==32) 
  2164.       {
  2165.       good = read(filehandle,HIDDEN,32000);
  2166.       }
  2167.     else
  2168.       {
  2169.       filesize=(unsigned)(lseek(filehandle,0L,2)-off[1]);
  2170.       lseek(filehandle,off[1],0);
  2171.       good = read(filehandle,MASK,filesize);
  2172.       if(good!=-1)decompress_screen(HIDDEN,MASK);
  2173.       }
  2174.     if (good == -1)
  2175.        {
  2176.        form_alert(1,"[1][ | Error loading image.   |    ][CANCEL]");
  2177.        return(FALSE);
  2178.        }
  2179.     close(filehandle);
  2180.     v_show_c(handle,0);
  2181.     }
  2182.  
  2183.  
  2184.  
  2185.  
  2186. decompress_screen(screen,source)
  2187.     register long screen[8000];
  2188.     long source[8000];
  2189.     {
  2190.     register int k,m,j=0,off,*tempi;
  2191.     int cntrl_max,I,t,r,g,b;
  2192.     long test;
  2193.     tempi=(int*)source;
  2194.     if (*tempi < 20 && STe_exists == TRUE) /* Fix palette made by */
  2195.       {                                     /* ST versions         */
  2196.       for (I=0;I<3200;I++)
  2197.         {
  2198.         t = 0xf00 & cb_pal[KEY][I];
  2199.         r = ( t > 0x700 ? 0x4000+2*(t-0x800) : 2*t );
  2200.         t = 0x0f0 & cb_pal[KEY][I];
  2201.         g = ( t > 0x070 ? 0x2000+2*(t-0x080) : 2*t );
  2202.         t = 0x00f & cb_pal[KEY][I];
  2203.         b = ( t > 0x007 ? 0x1000+2*(t-0x008) : 2*t );
  2204.         cb_pal[KEY][I]= r+g+b;
  2205.         }
  2206.       }
  2207.     if (*tempi >= 30) return;      /* punt, if unknown version     */
  2208.     stuff_current_cbpal(NEW);      /* load new palette             */
  2209.     cntrl_max=*(tempi+1);          /* get number of control words  */
  2210.     off=(cntrl_max-2)/2+1;
  2211.     for(k=2;k<cntrl_max;k++) 
  2212.         {
  2213.         my_control[k-2]=*(tempi+k);
  2214.         }
  2215.     for( k=0; k<cntrl_max-2; k++)
  2216.         {
  2217.         if(my_control[k]<0)  /* deal with compressed stuff */
  2218.             {
  2219.             for(m=0; m < -1*my_control[k]; m++)
  2220.                 screen[j++]=source[off];
  2221.             off++;
  2222.             }
  2223.         else                 /* deal with raw stuff */
  2224.             {
  2225.             for(m=0; m < my_control[k]; m++)
  2226.                 screen[j++]=source[off++];
  2227.             }
  2228.         }
  2229.     }
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235. save_picture(size,off)
  2236.     unsigned size;
  2237.     long off[2];
  2238.     {
  2239.     int filehandle,good,header[2];
  2240.     unsigned n0,n1;
  2241.     filehandle=open(filename,O_WRONLY|O_BINARY|O_CREAT);
  2242.     if (filehandle==-1)
  2243.        {
  2244.        form_alert(1,"[1][ | Error opening file.     |    ][CANCEL]");
  2245.        RING_BELL();
  2246.        return(FALSE);
  2247.        }
  2248.     if(size == 32)
  2249.       {
  2250.       n0 = off[0];
  2251.       header[0] = Getrez();                          /* Degas required   */
  2252.       n1 = off[1]-32-off[0];                         /* 0(D) or 92(neo)  */
  2253.       good = write(filehandle,header,n0);            /* write header     */
  2254.       good = write(filehandle,pic_palette[KEY],32);  /* write palette    */
  2255.       good = write(filehandle,s,n1);                 /* dummy neo scroll */
  2256.       if (good == -1)
  2257.         {
  2258.         form_alert(1,"[1][ | Error saving palette.   |    ][CANCEL]");
  2259.         return(FALSE);
  2260.         }
  2261.       good = write(filehandle,HIDDEN,32000);         /* write image data */
  2262.       if (good == -1)
  2263.         {
  2264.         form_alert(1,"[1][ | Error saving image.   |    ][CANCEL]");
  2265.         return(FALSE);
  2266.         }
  2267.       }
  2268.     else
  2269.       {
  2270.       good = write(filehandle,cb_pal[KEY],6400);
  2271.       if (good == -1)
  2272.         {
  2273.         form_alert(1,"[1][ | Error saving palette.   |    ][CANCEL]");
  2274.         return(FALSE);
  2275.         }
  2276.       copy_picture(HIDDEN,MASK);
  2277.       compress_screen(&size,MASK,MASK);
  2278.       good = write(filehandle,MASK,size);
  2279.       if (good == -1)
  2280.         {
  2281.         form_alert(1,"[1][ | Error saving image.   |    ][CANCEL]");
  2282.         return(FALSE);
  2283.         }
  2284.       }
  2285.     close(filehandle);
  2286.     RING_BELL();
  2287.     }
  2288.  
  2289.  
  2290.  
  2291. compress_screen(size,screen,destination)
  2292.     unsigned *size;
  2293.     long screen[8000],destination[8100];
  2294.     {
  2295.     register int k=1,my_count=0,m=2,j=0,*tempi;
  2296.     my_control[0]=20+Getrez();        /*** Version*10 + Resolution ***/
  2297.     test=screen[0];
  2298.     while(k< 8000)
  2299.         {
  2300.         while( k< 8000 && test==screen[k] )
  2301.             {
  2302.             k++;
  2303.             my_count++;
  2304.             }
  2305.         if(my_count>0)
  2306.             {
  2307.             my_control[m++]=-1*(my_count+1);
  2308.             my_count=0;
  2309.             my_buffer[j++]=test;
  2310.             if(k < 8000)test=screen[k];
  2311.             k++;
  2312.             }
  2313.         while( k< 8000 && test!=screen[k] )
  2314.             {
  2315.             my_count++;
  2316.             my_buffer[j++]=test;
  2317.             test=screen[k];
  2318.             k++;
  2319.             }
  2320.         if(my_count>0)
  2321.             {
  2322.             my_control[m++]=my_count;
  2323.             my_count=0;
  2324.             }
  2325.         }
  2326.     if( (m%2) == 1) m +=1;                /* make my_count even */
  2327.     my_control[1]=m;           /* store number of control words */
  2328.     tempi=(int*)&destination[0];
  2329.     for(k=0;k<m;k++) *(tempi+k) = my_control[k];
  2330.     for(k=0; k<j; k++) destination[k+(m/2)] = my_buffer[k];
  2331.     *size = (unsigned)(m*2+j*4);
  2332.     }
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338. display_help()
  2339.     {
  2340.     int message[8],x,y,button,state,key,n,I,
  2341.         bx,by,bw,bh,sx,sy,sw,sh,hold[16];
  2342.     Setpal(my_palette);
  2343.     form_center(help_1,&bx,&by,&bw,&bh);
  2344.     v_hide_c(handle);
  2345.     form_dial(FMD_GROW,0,work_out[1]-20,10,10,bx,by,bw,bh);
  2346.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  2347.     objc_draw(help_1,0,10,bx,by,bw,bh);
  2348.     v_show_c(handle,0);
  2349.     evnt_multi( MU_BUTTON ,1,3,1,0,0,0,0,0,0,0,0,0,0,message,
  2350.     0,0,&x,&y,&button,&state,&key,&n );
  2351.     v_hide_c(handle);
  2352.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  2353.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  2354.     if(objc_find(help_1,0,1,x,y)==EXIT1)
  2355.        {
  2356.        copy_picture(HIDDEN,SHOWN);
  2357.        Setpal(palette);
  2358.        v_show_c(handle,0);
  2359.        return(TRUE);
  2360.        }
  2361.     form_center(help_2,&bx,&by,&bw,&bh);
  2362.     form_dial(FMD_GROW,0,work_out[1]-20,10,10,bx,by,bw,bh);
  2363.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  2364.     objc_draw(help_2,0,10,bx,by,bw,bh);
  2365.     v_show_c(handle,0);
  2366.     evnt_multi( MU_BUTTON ,1,3,1,0,0,0,0,0,0,0,0,0,0,message,
  2367.     0,0,&x,&y,&button,&state,&key,&n );
  2368.     v_hide_c(handle);
  2369.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  2370.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  2371.     if(objc_find(help_2,0,1,x,y)==EXIT2)
  2372.        {
  2373.        copy_picture(HIDDEN,SHOWN);
  2374.        Setpal(palette);
  2375.        v_show_c(handle,0);
  2376.        return(TRUE);
  2377.        }
  2378.     form_center(help_3,&bx,&by,&bw,&bh);
  2379.     form_dial(FMD_GROW,0,work_out[1]-20,10,10,bx,by,bw,bh);
  2380.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  2381.     objc_draw(help_3,0,10,bx,by,bw,bh);
  2382.     v_show_c(handle,0);
  2383.     evnt_multi( MU_BUTTON ,1,3,1,0,0,0,0,0,0,0,0,0,0,message,
  2384.     0,0,&x,&y,&button,&state,&key,&n );
  2385.     v_hide_c(handle);
  2386.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  2387.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  2388.     if(objc_find(help_3,0,1,x,y)==EXIT3)
  2389.        {
  2390.        copy_picture(HIDDEN,SHOWN);
  2391.        Setpal(palette);
  2392.        v_show_c(handle,0);
  2393.        return(TRUE);
  2394.        }
  2395.     form_center(help_4,&bx,&by,&bw,&bh);
  2396.     form_dial(FMD_GROW,0,work_out[1]-20,10,10,bx,by,bw,bh);
  2397.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  2398.     objc_draw(help_4,0,10,bx,by,bw,bh);
  2399.     v_show_c(handle,0);
  2400.     evnt_multi( MU_BUTTON ,1,3,1,0,0,0,0,0,0,0,0,0,0,message,
  2401.     0,0,&x,&y,&button,&state,&key,&n );
  2402.     v_hide_c(handle);
  2403.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  2404.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  2405.     copy_picture(HIDDEN,SHOWN);
  2406.     Setpal(palette);
  2407.     v_show_c(handle,0);
  2408.     return(TRUE);
  2409.     }
  2410.  
  2411.  
  2412.  
  2413. goto_colorburst_mode(duration)
  2414.     int duration;
  2415.     {
  2416.     v_hide_c(handle);
  2417.     insert_cb_interrupt();
  2418.     Xbtimer(1,8,1,hblank);
  2419.     vcount=0;
  2420.     PAUSE(duration);
  2421.     Xbtimer(0,0,0,0L);
  2422.     remove_cb_interrupt();
  2423.     v_show_c(handle,0);
  2424.     Setpal(palette);
  2425.     return(TRUE);
  2426.     }
  2427.  
  2428.  
  2429.  
  2430. insert_cb_interrupt()
  2431.     {
  2432.     Vsync();
  2433.     Supexec(timer_setup);
  2434.     }
  2435.  
  2436.  
  2437.  
  2438. remove_cb_interrupt()
  2439.     {
  2440.     Supexec(clean_up);
  2441.     }
  2442.  
  2443.  
  2444.     asm
  2445.     {
  2446.   hblank:
  2447.     movem.l A3,-(A7)             /* Get a Register to work with.  */
  2448.     movea.l temp_line,A3
  2449.   setpal:
  2450.     move.l  (A3),0xff8240L
  2451.     move.l  4(A3),0xff8244L 
  2452.     move.l  8(A3),0xff8248L
  2453.     move.l  12(A3),0xff824cL 
  2454.     move.l  16(A3),0xff8250L 
  2455.     move.l  20(A3),0xff8254L 
  2456.     move.l  24(A3),0xff8258L 
  2457.     move.l  28(A3),0xff825cL 
  2458.   bye:
  2459.     addi.l  #32,temp_line
  2460.     movem.l (A7)+,A3            /* Restore registers before leaving  */
  2461.     bclr.b  #0,0xfffa0b         /* clear interrupt with mfp 68901    */
  2462.     bclr.b  #0,0xfffa0f         /* clear interrupt pending on mfp    */
  2463.     rte                         /* Return from the timer exception   */
  2464.     }
  2465.  
  2466.  
  2467.  
  2468.     asm
  2469.     {                          /* Timer B is used for hblanks.      */
  2470.   vblank:
  2471.     subq.b  #1,0xfffa13  
  2472.     movem.l A3,-(A7)           /* Get some Registers to work with.  */
  2473.     cmpi.w  #1,pause_flag
  2474.     bne     Go_on
  2475.     addi.w  #1,vcount          /* If we are 'Paused' increment the  */
  2476.     bra     Go_on              /* 60 hz timing counter.             */
  2477.   Go_on:
  2478.     lea     cb1_palette,A3     /* Use 1st set of palettes           */
  2479.     neg     ptoggle
  2480.     cmpi.w  #1,ptoggle
  2481.     beq     bye
  2482.     lea     cb2_palette,A3     /* Use 2nd set of palettes           */
  2483.   bye:
  2484.     move.l  A3,temp_line       /* Set palette pointer               */
  2485.     movem.l (A7)+,A3           /* Restore registers before leaving  */
  2486.     ori.b   #1,0xfffa13   
  2487.     rts                        /* return to process the rest of     */
  2488.     }                          /* the Vblank exception.             */
  2489.  
  2490.  
  2491.  
  2492. timer_setup()
  2493.     {
  2494.     short stop_keyboard;
  2495.     stop_keyboard=0x13;
  2496.     Ikbdws(1,&stop_keyboard);
  2497.     asm{
  2498.     movem.l A1-A3,-(A7)    /* Get some Registers to work with.  */
  2499.   store:
  2500.     move.b 0xfffa07,_1st_enable_register       /* Save old      */
  2501.     move.b 0xfffa09,_2nd_enable_register       /* values for    */
  2502.     move.b 0xfffa13,_1st_mask_register         /* later resto-  */
  2503.                                                /* ration.       */
  2504.   set_up:
  2505.     lea     vblank,A1             /* insert new vblank routine      */
  2506.     move.l  A1,0x4d2
  2507.     andi.b  #0xdf,0xfffa09
  2508.     lea     cb1_palette,A3        /* Set palette pointer            */
  2509.     move.l  A3,temp_line
  2510.     movem.l (A7)+,A1-A3           /* Reset registers before leaving */
  2511.     unlk    A6 
  2512.     rts
  2513.     }
  2514.     }
  2515.  
  2516.  
  2517.  
  2518. clean_up()
  2519.     {
  2520.     short reset_keyboard;
  2521.     reset_keyboard=0x11;
  2522.     Ikbdws(1,&reset_keyboard);
  2523.     asm{
  2524.  restore:
  2525.     move.l #0x0L,0x4d2
  2526.     move.b _1st_enable_register,0xfffa07     /* Restore old     */
  2527.     move.b _2nd_enable_register,0xfffa09     /* values to these */
  2528.     move.b _1st_mask_register,0xfffa13       /* MFP 68901 reg.s */
  2529.     unlk A6 
  2530.     rts
  2531.     }
  2532.     }
  2533.  
  2534.  
  2535.  
  2536. clear_vblank()
  2537.     {
  2538.     asm
  2539.     {
  2540.     move.l #0x0L,0x4d2    /* Delete extra vblank vector */
  2541.     unlk A6 
  2542.     rts
  2543.     }
  2544.     }
  2545.  
  2546.  
  2547. Setpal(pal)
  2548.     int pal[16];
  2549.     {
  2550.     int I;
  2551.     for(I=0;I<16;I++) STe_color(I,pal[I]);   /*** STe palette fix   ***/
  2552.     }
  2553.  
  2554.  
  2555. STe_color(I,rgb)
  2556.     int I,rgb; 
  2557.     {
  2558.     int r,g,b;
  2559.     r = (rgb & 0x0f00)/0x0100;                 /* isolate RED nibble   */
  2560.     g = (rgb & 0x00f0)/0x0010;                 /* isolate GREEN nibble */
  2561.     b = (rgb & 0x000f);                        /* isolate BLUE nibble  */
  2562.     Setcolor(I,STe_rgb[r]*0x100
  2563.             +STe_rgb[g]*0x010+STe_rgb[b]);     /* set new version      */
  2564.     }
  2565.  
  2566.  
  2567. rubber_spray(x,y,xf,yf)
  2568.     int x,y,*xf,*yf;
  2569.     {
  2570.     int hold,d,button = RIGHT;
  2571.     hold=lwidth;
  2572.     vsl_width(handle,1);
  2573.     *xf=x+spray_xr;
  2574.     *yf=y+spray_yr;
  2575.     vswr_mode(handle,3);
  2576.     v_ellarc(handle,x,y,*xf-x,*yf-y,0,3600);
  2577.     for(d=0;d++<50;)Vsync();
  2578.     v_ellarc(handle,x,y,*xf-x,*yf-y,0,3600);
  2579.     v_hide_c(handle);
  2580.     while(button != NONE) vq_mouse(handle,&button,xf,yf);
  2581.     while(button == NONE)
  2582.       {
  2583.       vq_mouse(handle,&button,xf,yf);
  2584.       if(abs(*yf-y)>y/2) *yf=y/2;
  2585.       if(abs(*xf-x)>x/2) *xf=x/2;
  2586.       v_ellarc(handle,x,y,*xf-x,*yf-y,0,3600);
  2587.       Vsync();
  2588.       v_ellarc(handle,x,y,*xf-x,*yf-y,0,3600);
  2589.       }
  2590.     vswr_mode(handle,linewmode);
  2591.     vsl_width(handle,hold);
  2592.     v_show_c(handle,0);
  2593.     if (button == LEFT) 
  2594.      {
  2595.      while(button != NONE) vq_mouse(handle,&button,&d,&d);
  2596.      return(TRUE);
  2597.      }
  2598.     return(FALSE);
  2599.     }
  2600.  
  2601.  
  2602.  
  2603. rubber_ellipse(x,y,xf,yf)
  2604.     int x,y,*xf,*yf;
  2605.     {
  2606.     int hold,d,button = RIGHT;
  2607.     hold=lwidth;
  2608.     vsl_width(handle,1);
  2609.     *xf=x;
  2610.     *yf=y;
  2611.     vswr_mode(handle,3);
  2612.     v_hide_c(handle);
  2613.     while(button != NONE) vq_mouse(handle,&button,xf,yf);
  2614.     while(button == NONE)
  2615.       {
  2616.       vq_mouse(handle,&button,xf,yf);
  2617.       v_ellarc(handle,x,y,*xf-x,*yf-y,0,3610);
  2618.       Vsync();
  2619.       v_ellarc(handle,x,y,*xf-x,*yf-y,0,3610);
  2620.       }
  2621.     vswr_mode(handle,linewmode);
  2622.     vsl_width(handle,hold);
  2623.     v_show_c(handle,0);
  2624.     if (button == LEFT) 
  2625.      {
  2626.      while(button != NONE) vq_mouse(handle,&button,&d,&d);
  2627.      return(TRUE);
  2628.      }
  2629.     return(FALSE);
  2630.     }
  2631.  
  2632.  
  2633. rubber_box(x,y,xf,yf)
  2634.     int x,y,*xf,*yf;
  2635.     {
  2636.     int d,box_array[10],button = RIGHT;
  2637.     vsl_width(handle,1);
  2638.     box_array[0] = box_array[6] = box_array[8] = x;
  2639.     box_array[1] = box_array[3] = box_array[9] = y;
  2640.     vswr_mode(handle,3);
  2641.     v_hide_c(handle);
  2642.     while(button != NONE) vq_mouse(handle,&button,xf,yf);
  2643.     while(button == NONE)
  2644.       {
  2645.       vq_mouse(handle,&button,xf,yf);
  2646.       box_array[2] = box_array[4] = *xf;
  2647.       box_array[5] = box_array[7] = *yf;
  2648.       v_pline(handle,5,box_array);
  2649.       Vsync();
  2650.       v_pline(handle,5,box_array);
  2651.       Vsync();
  2652.       }
  2653.     vsl_width(handle,lwidth);
  2654.     vswr_mode(handle,linewmode);
  2655.     v_show_c(handle,0);
  2656.     if (button == LEFT) 
  2657.      {
  2658.      while(button != NONE) vq_mouse(handle,&button,&d,&d);
  2659.      return(TRUE);
  2660.      }
  2661.     return(FALSE);
  2662.     }
  2663.  
  2664.  
  2665.  
  2666. set_line()
  2667.     {
  2668.     int p[4],temp;
  2669.     objc_offset(colorbox,SHOW_BOX,&p[0],&p[1]);
  2670.     p[2] = colorbox[SHOW_BOX].ob_width;
  2671.     p[3] = colorbox[SHOW_BOX].ob_height;
  2672.     v_hide_c(handle);
  2673.     objc_draw(colorbox,SHOW_BOX,0,p[0],p[1],p[2],p[3]);
  2674.     p[1] = p[3] = p[1] + p[3]/2;
  2675.     p[2] = p[2] - 1 + p[0];
  2676.     v_pline(handle,2,p);
  2677.     Vsync();
  2678.     v_show_c(handle,0);
  2679.     }
  2680.  
  2681.  
  2682.  
  2683. set_text()
  2684.     {
  2685.     int p[4],temp;
  2686.     char s[4];
  2687.     objc_offset(colorbox,SHOW_BOX,&p[0],&p[1]);
  2688.     p[2] = colorbox[SHOW_BOX].ob_width;
  2689.     p[3] = colorbox[SHOW_BOX].ob_height;
  2690.     objc_draw(colorbox,SHOW_BOX,0,p[0],p[1],p[2],p[3]);
  2691.     vswr_mode(handle,TRANSPARENT); 
  2692.     sprintf(s,"%d",text_h);
  2693.     v_hide_c(handle);
  2694.     v_gtext(handle,p[0]+p[2]/5,p[1]+p[3]-4,s);
  2695.     Vsync();
  2696.     v_show_c(handle,0);
  2697.     vswr_mode(handle,linewmode);
  2698.     }
  2699.  
  2700.  
  2701.  
  2702. set_fill()
  2703.     {
  2704.     int p[4],temp;
  2705.     objc_offset(colorbox,SHOW_BOX,&p[0],&p[1]);
  2706.     p[2] = colorbox[SHOW_BOX].ob_width;
  2707.     p[3] = colorbox[SHOW_BOX].ob_height;
  2708.     objc_draw(colorbox,SHOW_BOX,0,p[0],p[1],p[2],p[3]);
  2709.     temp = p[1];
  2710.     p[1] = p[1] + p[3] - 1;
  2711.     p[2] = p[2] - 1 + p[0];
  2712.     p[3] = temp;
  2713.     v_hide_c(handle);
  2714.     v_bar(handle,p);
  2715.     Vsync();
  2716.     v_show_c(handle,0);
  2717.     }
  2718.  
  2719.  
  2720.  
  2721. set_object(tree,item,state)
  2722.     OBJECT *tree;
  2723.     int item,state;
  2724.     {
  2725.     int p[4];
  2726.     objc_offset(tree,item,&p[0],&p[1]);
  2727.     p[2] = tree[item].ob_width;
  2728.     p[3] = tree[item].ob_height;
  2729.     objc_change(tree,item,0,p[0],p[1],p[2],p[3],state,1);
  2730.     }
  2731.  
  2732.  
  2733.  
  2734. advance_selection(set_flag)
  2735.     int set_flag;
  2736.     {
  2737.     int I,k,button,x,y,attrib[6],rez,cw,ch,cellw,cellh;
  2738.     rez=Getrez();
  2739.     switch(set_flag)
  2740.       {
  2741.       case SELECT_F:
  2742.           vqf_attributes(handle,attrib);
  2743.           k = attrib[0];
  2744.           I = attrib[2];
  2745.           if( k==3 && I==12)
  2746.             {
  2747.             k=2;
  2748.             I=1;
  2749.             }
  2750.           if( ++I >24 )
  2751.             {
  2752.             I=1;
  2753.             k=3;
  2754.             }
  2755.           vsf_interior(handle,k);
  2756.           vsf_style(handle,I);
  2757.           set_fill();
  2758.           break;
  2759.       case LINE_W:
  2760.           if( (lwidth+=2+rez*2) > 29 ) lwidth=1;
  2761.           vsl_width(handle,lwidth);
  2762.           set_line();
  2763.           if(lwidth!=1)set_object(colorbox,LINE_S,CROSSED);
  2764.           if(lwidth==1)set_object(colorbox,LINE_S,NORMAL);
  2765.           break;
  2766.       case LINE_S:
  2767.           vql_attributes(handle,attrib);
  2768.           I = attrib[0];
  2769.           if( ++I > 6 ) I=1;
  2770.           vsl_type(handle,I);
  2771.           set_line();
  2772.           break;
  2773.       case SELECT_T:
  2774.           if( ++text_h > 26 ) text_h=4;
  2775.           vst_height(handle,text_h,&cw,&ch,&cellw,&cellh);
  2776.           set_text();
  2777.           break;
  2778.       }
  2779.     for(I=0;I<15;I++) Vsync();
  2780.     }
  2781.  
  2782.  
  2783.  
  2784.  
  2785. decrement_selection(set_flag)
  2786.     int set_flag;
  2787.     {
  2788.     int I,k,button,x,y,attrib[6],rez,cw,ch,cellw,cellh;
  2789.     rez=Getrez();
  2790.     switch(set_flag)
  2791.       {
  2792.       case SELECT_F:
  2793.           vqf_attributes(handle,attrib);
  2794.           k = attrib[0];
  2795.           I = attrib[2];
  2796.           if( k==3 && I==1)
  2797.             {
  2798.             k=2;
  2799.             I=24;
  2800.             }
  2801.           if( --I < 1 )
  2802.             {
  2803.             I=12;
  2804.             k=3;
  2805.             }
  2806.           vsf_interior(handle,k);
  2807.           vsf_style(handle,I);
  2808.           set_fill();
  2809.           break;
  2810.       case LINE_W:
  2811.           if( (lwidth-=2+rez*2) < 1 ) lwidth = 29;
  2812.           vsl_width(handle,lwidth);
  2813.           set_line();
  2814.           if(lwidth!=1)set_object(colorbox,LINE_S,CROSSED);
  2815.           if(lwidth==1)set_object(colorbox,LINE_S,NORMAL);
  2816.           break;
  2817.       case LINE_S:
  2818.           vql_attributes(handle,attrib);
  2819.           I = attrib[0];
  2820.           if( --I < 1 ) I = 3;
  2821.           vsl_type(handle,I);
  2822.           set_line();
  2823.           break;
  2824.       case SELECT_T:
  2825.           if( --text_h < 4 ) text_h=26;
  2826.           vst_height(handle,text_h,&cw,&ch,&cellw,&cellh);
  2827.           set_text();
  2828.           break;
  2829.       }
  2830.     for(I=0;I<15;I++) Vsync();
  2831.     }
  2832.  
  2833.  
  2834.  
  2835. call_other_program()
  2836.     {
  2837.     int response;
  2838.     char *no_other = "[0][ |Error loading your program | ][ Sorry ]";
  2839.     clear_screen(SHOWN);
  2840.     Setpalette(desk_palette);
  2841.     response = chose_a_file("*.PRG",PROGRAM);
  2842.     if(response==FALSE)
  2843.       {
  2844.       Setpal(palette);
  2845.       copy_picture(HIDDEN,SHOWN);
  2846.       return;
  2847.       }
  2848.     response = Pexec(0,filename,"",0L);
  2849.     copy_picture(HIDDEN,SHOWN);
  2850.     Setpal(palette); 
  2851.     if (response < 0 ) form_alert(1,no_other);
  2852.     }
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859. set_rgb(tree,pen,item)
  2860.     int pen,item;
  2861.     OBJECT* tree;
  2862.     {
  2863.     char text[4];
  2864.     int I,color,p[4],r,g,b,rgb,k,medmap[4],lowmap[16];
  2865.     medmap[0]=0;
  2866.     medmap[1]=3;
  2867.     medmap[2]=1;
  2868.     medmap[3]=2;
  2869.     lowmap[0]=0;
  2870.     lowmap[1]=15;
  2871.     lowmap[2]=1;
  2872.     lowmap[3]=2;
  2873.     lowmap[4]=4;
  2874.     lowmap[5]=6;
  2875.     lowmap[6]=3;
  2876.     lowmap[7]=5;
  2877.     lowmap[8]=7;
  2878.     lowmap[9]=8;
  2879.     lowmap[10]=9;
  2880.     lowmap[11]=10;
  2881.     lowmap[12]=12;
  2882.     lowmap[13]=14;
  2883.     lowmap[14]=11;
  2884.     lowmap[15]=13;
  2885.     v_hide_c(handle);
  2886.     color = ((int)tree[pen].ob_spec) & 0x000f;
  2887.     active_pen = color;
  2888.     color = (Getrez()==1) ? medmap[color]:lowmap[color];
  2889.     r = ((pic_palette[KEY][color] & 0xf00)/0x100) +
  2890.         16*((pic_palette[KEY][color] & 0x4000)/0x4000);
  2891.     g = ((pic_palette[KEY][color] & 0x0f0)/0x010) +
  2892.         16*((pic_palette[KEY][color] & 0x2000)/0x2000);
  2893.     b = (pic_palette[KEY][color] & 0xf) +
  2894.         16*((pic_palette[KEY][color] & 0x1000)/0x1000);
  2895.     switch (item)
  2896.       {
  2897.       case R_UP:
  2898.            if( ( r+=1 )>max_shade ) r=max_shade;
  2899.            sprintf(text,"%02d",r);
  2900.            ((TEDINFO *)tree[R_VALUE].ob_spec)->te_ptext = text;
  2901.            ((TEDINFO *)tree[R_VALUE].ob_spec)->te_txtlen = 2;
  2902.            objc_offset(tree,R_VALUE,&p[0],&p[1]);
  2903.            p[2] = tree[R_VALUE].ob_width;
  2904.            p[3] = tree[R_VALUE].ob_height;
  2905.            objc_draw(tree,R_VALUE,1,p[0],p[1],p[2],p[3]);
  2906.            break;
  2907.       case G_UP:
  2908.            if( ( g += 1 )>max_shade ) g=max_shade;
  2909.            sprintf(text,"%02d",g);
  2910.            ((TEDINFO *)tree[G_VALUE].ob_spec)->te_ptext = text;
  2911.            ((TEDINFO *)tree[G_VALUE].ob_spec)->te_txtlen = 2;
  2912.            objc_offset(tree,G_VALUE,&p[0],&p[1]);
  2913.            p[2] = tree[G_VALUE].ob_width;
  2914.            p[3] = tree[G_VALUE].ob_height;
  2915.            objc_draw(tree,G_VALUE,1,p[0],p[1],p[2],p[3]);
  2916.            break;
  2917.       case B_UP:
  2918.            if( ( b+=1 )>max_shade ) b=max_shade;
  2919.            sprintf(text,"%02d",b);
  2920.            ((TEDINFO *)tree[B_VALUE].ob_spec)->te_ptext = text;
  2921.            ((TEDINFO *)tree[B_VALUE].ob_spec)->te_txtlen = 2;
  2922.            objc_offset(tree,B_VALUE,&p[0],&p[1]);
  2923.            p[2] = tree[B_VALUE].ob_width;
  2924.            p[3] = tree[B_VALUE].ob_height;
  2925.            objc_draw(tree,B_VALUE,1,p[0],p[1],p[2],p[3]);
  2926.            break;
  2927.       case R_DOWN:
  2928.            if( ( r-=1 )<0 ) r=0;
  2929.            sprintf(text,"%02d",r);
  2930.            ((TEDINFO *)tree[R_VALUE].ob_spec)->te_ptext = text;
  2931.            ((TEDINFO *)tree[R_VALUE].ob_spec)->te_txtlen = 2;
  2932.            objc_offset(tree,R_VALUE,&p[0],&p[1]);
  2933.            p[2] = tree[R_VALUE].ob_width;
  2934.            p[3] = tree[R_VALUE].ob_height;
  2935.            objc_draw(tree,R_VALUE,1,p[0],p[1],p[2],p[3]);
  2936.            break;
  2937.       case G_DOWN:
  2938.            if( ( g-=1 )<0 ) g=0;
  2939.            sprintf(text,"%02d",g);
  2940.            ((TEDINFO *)tree[G_VALUE].ob_spec)->te_ptext = text;
  2941.            ((TEDINFO *)tree[G_VALUE].ob_spec)->te_txtlen = 2;
  2942.            objc_offset(tree,G_VALUE,&p[0],&p[1]);
  2943.            p[2] = tree[G_VALUE].ob_width;
  2944.            p[3] = tree[G_VALUE].ob_height;
  2945.            objc_draw(tree,G_VALUE,1,p[0],p[1],p[2],p[3]);
  2946.            break;
  2947.       case B_DOWN:
  2948.            if( ( b-=1 )<0 ) b=0;
  2949.            sprintf(text,"%02d",b);
  2950.            ((TEDINFO *)tree[B_VALUE].ob_spec)->te_ptext = text;
  2951.            ((TEDINFO *)tree[B_VALUE].ob_spec)->te_txtlen = 2;
  2952.            objc_offset(tree,B_VALUE,&p[0],&p[1]);
  2953.            p[2] = tree[B_VALUE].ob_width;
  2954.            p[3] = tree[B_VALUE].ob_height;
  2955.            objc_draw(tree,B_VALUE,1,p[0],p[1],p[2],p[3]);
  2956.            break;
  2957.       default:
  2958.            sprintf(text,"%02d",r);
  2959.            ((TEDINFO *)tree[R_VALUE].ob_spec)->te_ptext = text;
  2960.            ((TEDINFO *)tree[R_VALUE].ob_spec)->te_txtlen = 2;
  2961.            objc_offset(tree,R_VALUE,&p[0],&p[1]);
  2962.            p[2] = tree[R_VALUE].ob_width;
  2963.            p[3] = tree[R_VALUE].ob_height;
  2964.            objc_draw(tree,R_VALUE,1,p[0],p[1],p[2],p[3]);
  2965.            sprintf(text,"%02d",g);
  2966.            ((TEDINFO *)tree[G_VALUE].ob_spec)->te_ptext = text;
  2967.            ((TEDINFO *)tree[G_VALUE].ob_spec)->te_txtlen = 2;
  2968.            objc_offset(tree,G_VALUE,&p[0],&p[1]);
  2969.            p[2] = tree[G_VALUE].ob_width;
  2970.            p[3] = tree[G_VALUE].ob_height;
  2971.            objc_draw(tree,G_VALUE,1,p[0],p[1],p[2],p[3]);
  2972.            sprintf(text,"%02d",b);
  2973.            ((TEDINFO *)tree[B_VALUE].ob_spec)->te_ptext = text;
  2974.            ((TEDINFO *)tree[B_VALUE].ob_spec)->te_txtlen = 2;
  2975.            objc_offset(tree,B_VALUE,&p[0],&p[1]);
  2976.            p[2] = tree[B_VALUE].ob_width;
  2977.            p[3] = tree[B_VALUE].ob_height;
  2978.            objc_draw(tree,B_VALUE,1,p[0],p[1],p[2],p[3]);
  2979.            v_show_c(handle,0);
  2980.            return(TRUE);
  2981.            break;
  2982.            }
  2983.     r = (r>15 ? (r-16)*0x100 + 0x4000 : r*0x100);
  2984.     g = (g>15 ? (g-16)*0x010 + 0x2000 : g*0x010);
  2985.     b = (b>15 ? (b-16) + 0x1000 : b);
  2986.     rgb = r + b + g;
  2987.     pic_palette[KEY][color]=rgb;
  2988.     for(I=0;I<16;I++)
  2989.       {
  2990.       r = ((pic_palette[KEY][I] & 0xf00)/0x100 + 
  2991.          16*((pic_palette[KEY][I] & 0x4000)/0x4000))/2;
  2992.       g = ((pic_palette[KEY][I] & 0x0f0)/0x010 + 
  2993.          16*((pic_palette[KEY][I] & 0x2000)/0x2000))/2;
  2994.       b = ((pic_palette[KEY][I] & 0x00f) + 
  2995.          16*((pic_palette[KEY][I] & 0x1000)/0x1000))/2;
  2996.       palette[I]=r*0x100+g*0x010+b;
  2997.       }
  2998.     Setpal(palette);
  2999.     v_show_c(handle,0);
  3000.     }
  3001.  
  3002.  
  3003.  
  3004. select_sprayer()
  3005.     {
  3006.     int x,y,mid_row,mid_col;
  3007.     mid_row = (Getrez() == 2 ? 200 : 100);
  3008.     mid_col = (Getrez() == 0 ? 160 : 320);
  3009.     if(rubber_spray(mid_col,mid_row,&x,&y)==TRUE)
  3010.       {
  3011.       if( (spray_xr=x-mid_col)< 0) spray_xr *= -1;
  3012.       if( (spray_yr=y-mid_row)< 0) spray_yr *= -1;
  3013.       }
  3014.     copy_picture(MASK,SHOWN);
  3015.     }
  3016.  
  3017.  
  3018.  
  3019.  
  3020. reset_color(flag)
  3021.     int flag;
  3022.     {
  3023.     int I,K,color,shade,medmap[4],lowmap[16];
  3024.     medmap[0]=0;
  3025.     medmap[1]=3;
  3026.     medmap[2]=1;
  3027.     medmap[3]=2;
  3028.     lowmap[0]=0;
  3029.     lowmap[1]=15;
  3030.     lowmap[2]=1;
  3031.     lowmap[3]=2;
  3032.     lowmap[4]=4;
  3033.     lowmap[5]=6;
  3034.     lowmap[6]=3;
  3035.     lowmap[7]=5;
  3036.     lowmap[8]=7;
  3037.     lowmap[9]=8;
  3038.     lowmap[10]=9;
  3039.     lowmap[11]=10;
  3040.     lowmap[12]=12;
  3041.     lowmap[13]=14;
  3042.     lowmap[14]=11;
  3043.     lowmap[15]=13;
  3044.     color = (Getrez()==1) ? medmap[active_pen]:lowmap[active_pen];
  3045.     v_hide_c(handle);
  3046.     if(flag == NEW) 
  3047.       {
  3048.       shade = pic_palette[KEY][color];          /* use new color    */
  3049.       }
  3050.     else
  3051.       {
  3052.       shade = old_shade[color];                 /* use old color    */
  3053.       }
  3054.     old_shade[color] = pic_palette[KEY][color]; /* update old color */
  3055.     K=list[0];
  3056.     for(I=1;I<200;I++)list[I-1]=list[I];        /* rotate colored   */
  3057.     list[199]=K;                                /* region           */
  3058.     for(I=0;I<200;I++)
  3059.       {
  3060.       if(list[I]==1 || locked==TRUE) cb_pal[KEY][I*16+color] = shade;
  3061.       }
  3062.     stuff_current_cbpal(OLD);
  3063.     v_show_c(handle,0);
  3064.     }
  3065.  
  3066.  
  3067. show_tos_version()
  3068.     {
  3069.     int max_colors,bx,by,bw,bh,K;
  3070.     unsigned short major,minor,I;
  3071.     char roms[18],romcolor[23];
  3072.     RING_BELL();
  3073.     form_center(rom_vers,&bx,&by,&bw,&bh);
  3074.     v_hide_c(handle);
  3075.     form_dial(FMD_GROW,0,work_out[1]-20,10,10,bx,by,bw,bh);
  3076.     form_dial(FMD_START,0,0,0,0,bx,by,bw,bh);
  3077.     rom_version.tos_version = global[0];
  3078.     major = rom_version.part[0];
  3079.     minor = I =  rom_version.part[1];
  3080.     while(minor>10) minor /= 10;
  3081.     if (minor>=6) for(K=0;K<16;K++) my_palette[K] *=2;
  3082.     Setpal(my_palette);
  3083.     max_colors = ( minor >= 6 ? 29791 : 3375 );
  3084.     max_shade = ( minor >= 6 ? 30 : 14 );    /* Range: 0-14 ST or 0-30 STe */
  3085.     sprintf(roms,"version %d.%-2d ROMs",major,I);
  3086.     ((TEDINFO *) rom_vers[ROMS].ob_spec)->te_ptext = roms;
  3087.     ((TEDINFO *) rom_vers[ROMS].ob_spec)->te_txtlen = 17;
  3088.     sprintf(romcolor,"%5d colors available",max_colors);
  3089.     ((TEDINFO *) rom_vers[ROMCOLOR].ob_spec)->te_ptext = romcolor;
  3090.     ((TEDINFO *) rom_vers[ROMCOLOR].ob_spec)->te_txtlen = 22;
  3091.     objc_draw(rom_vers,0,10,bx,by,bw,bh);
  3092.     v_show_c(handle,0);
  3093.     for (K=0;K<180;K++) Vsync();      /* wait 3 seconds */
  3094.     v_hide_c(handle);
  3095.     form_dial(FMD_SHRINK,10,10,10,10,bx,by,bw,bh);
  3096.     form_dial(FMD_FINISH,0,0,0,0,bx,by,bw,bh);
  3097.     if(minor<6) 
  3098.       {
  3099.       for(I=0;I<16;I++)STe_rgb[I]=I; /* if ST, bypass STe fix */
  3100.       return(FALSE);
  3101.       }
  3102.     return(TRUE);
  3103.     }
  3104.  
  3105.